Use one language definition inside another? - syntax-highlighting

I'm writing a language definition for sublime text for the Kinetic Rule Language. In KRL, there are some places where you can write HTML or Javascript, so I want to let the Javascript and HTML language definitions take over for these blocks.
I thought it would be as simple as just specifying text.html or source.js for the scope name, but that doesn't seem to work. Can anyone shed some light on the proper way to do this?

If you define the regions in which HTML or javascript will be defined, you can define a start and end regular expressions, and include the language. It's described a little more in Sublime Text 2: Different language highlighting based on context? (a la Webstorm).
If instead you want to include it globally (for instance if you were simply extending the language), you can add the following as an entry under "patterns".
<dict>
<key>include</key>
<string>source.js</string>
</dict>
<dict>
<key>include</key>
<string>text.html</string>
</dict>

Related

How to exclude some entries from TOC

I'm using the wkhtmltopdf to create some documents that require a TOC; this is done using Hx tags and it works properly (including a modified XSL file). The input HTML is generated by my own code, so I have full control over it.
Now, I need to exclude some, but not all entries at a certain level, like in the sample below
<h1>First</h1>
<h2>First of first</h2> <- exclude
<h2>Second of first</h2> <- exclude
<h1>Second</h1>
<h2>First of second</h2>
<h2>Second of second</h2>
The documentation explains how to customize the XSL; so I have generated the outline for the document and looked at the XML file.
It contains, as described in the manual, elements with four attributes : title, page, link and backLink.
<outline xmlns="http://wkhtmltopdf.org/outline">
<item title="First" page="0" link="__WKANCHOR_0" backLink="__WKANCHOR_1">
<item title="First of first" page="1" link="__WKANCHOR_2" backLink="__WKANCHOR_3"/>
<item title="Second of first" page="1" link="__WKANCHOR_4" backLink="__WKANCHOR_5">
... and so on
I guess that in order to get the desired result there could be two ways :
alter the way the outline is created, or
alter the way the outline is processed
I could not find a way to achieve the first option, and the outline file has not enough information to use in the XSL file.
A couple of notes :
I know I can exclude by title attribute, but the documents may have a lot of them, so excluding by title isn't really an option.
another reason it can't be done is because I may exclude an entry at a certain location but need to include one with the same title elsewhere.
obviously I cannot exclude by page name, since I cannot possibly know in advance where the pages will break.
it would be nice to have those entries in the document outline but not in the TOC, so probably the second way to achieve this would be the proper way.
... so any help is appreciated. Thanks.
After a bit of struggling, here's a solution.
Since I cannot alter the outline file or creation method without tapping into wkhtmltopdf's source files, I tried to find a way to tell apart the TOC entries I want from those I don't want, based on the only available properties; I chose the title since it's the most easy to control.
Enter the "zero-width non-joiner" : ‌
I added this special character as the first element of the TOC entries I don't want, then used the following test within the TOC XSL file.
<xsl:if test="not(starts-with(#title, '‌'))">
This simple trick seems to do the job properly.

How to customize sample.lua for pandoc

I just tried the sample, https://github.com/jgm/pandoc/blob/master/data/sample.lua for pandoc and it works.
I seek a little documentation on what I can edit in it?
Is all document parts defined from the lua functions?
I am reading from a latex document and have two tasks i would like to solve if possible.
Can i wrap each section / chapters in latex in a div, and add classes to them?
Can i put a abstract class on the div element that comes from the abstract.

How to enable Mathematica syntax highlighting for MediaWiki using extension "SyntaxHighlight GeSHi"?

I'd like to syntax highlight Mathematica code on a MediaWiki site. I've already installed
the MediaWiki extension SyntaxHighlight GeSHi and verified that it works for other languages.
I tried simply putting a Mathematica langauge data file mathematica.php into MediaWiki's extension path wiki/extensions/SyntaxHighlight_GeSHi/geshi, however it didn't correctly highlight a Mathematica code block such as:
<syntaxhighlight lang="Mathematica">
(* this is a comment *)
List[Sin[x], Cos[x], Tan[x]];
</syntaxhighlight>
Any ideas?
I do not see Mathematica listed as a supported language at http://qbnz.com/highlighter/, so I suppose GeSHi simply doesn't know it. I suppose you could contribute the respective highlighting code to the geshi project, if you like.
you need modify geshi.php, function get_language_name_from_extension to be specific, for added language definition to be recognized.

XSL transformation in Firefox, how to omit xmlns in returned transform?

I am trying to do XSL transformation in javascript in Firefox 3.5. The transformed value has something like this:
<span xmlns="http://www.w3.org/1999/xhtml/">...</span>
How can I ensure that the xmlns isn't set here? This happens only in Firefox and not IE.
Why do you want to remove the namespace?
The purpose of namespaces are not always well understood or appreciated.
If you are transforming to XHTML, the namespace is valid (and can be useful). It tells you(and more importantly, the browser) what type of span element you are dealing with so you can decide how to render it. Depending on the vocabulary, or the version of the vocabulary, you may decide to handle the XML differently.

Multiple-line cursor movements in XCode

I'd like to map a key to move the cursor in the XCode up by ten lines. Of course, I want another one to move down too. The key mapping would ideally be something like 'Control-Alt-P'.
Is there a way to achieve this in XCode without resorting to Automator?
Ashley has the answer below, the formatting was a little different as the property list is in XML format.
In summary, added an entry in the following format to the 'text' section of *.pbxkeys in ~/Library/Application Support/Xcode/Key Bindings/:
<key>^~p</key>
<array>
<string>moveUp:</string>
<string>moveUp:</string>
</array>
You can use the example given here and use a DefaultKeyBinding.dict file, except use moveUp: and moveDown: as your selectors.
Your particular dictionary entry would look something like this:
{
"^~P" = (
"moveUp:",
"moveUp:",
"moveUp:",
... however many times ...
"moveUp:",
);
}
I have since learned that if you have customized your keybindings through Xcode already you should instead add the same dictionary entry to your .pbxkeys file under the text dictionary section.
Just a reminder for the impatient who didn't read all the way to the end of oldbeamer's question and are also looking to use .pbxkeys instead of .dict:
If you are wanting to add multi-action keybindings to your pbxkeys file, the XML formatting goes like this:
<key>...</key>
<array>
<string>action1:</string>
<string>action2:</string>
<string>etc:</string>
</array>
You can edit the .pbxkeys directly using a text editor to add custom multi-action keybindings this way.

Resources