Help:Syntax Highlighting: Difference between revisions

m
→‎Supported languages: left a word out
m (→‎Recommended language tag usage: don't bother trying to maintain a separate list, just point to official)
m (→‎Supported languages: left a word out)
 
(3 intermediate revisions by the same user not shown)
Line 1:
Rosetta Code supports syntax highlighting of code using [httphttps://sourceforgepygments.net/projects/geshiorg/ GeSHiPygments], the Generic Syntax Highlighter.
 
== How to highlight ==
Prefix your code with <code>&lt;syntaxhighlight lang ''="foo''"&gt;</code> (where ''foo'' is the language to use for highlighting) and suffix it with <code>&lt;/langsyntaxhighlight&gt;</code>. Be sure not to insert extra space between the tags and your code. For example, here's how you'd highlight a C program:
 
<pre>
Line 19:
 
== Supported languages ==
Make sure to use the standard identifier for your language even if GeSHiPygments doesn't know how to highlight it yet. If your language isn't in the list, make up an identifier (consisting entirely of lowercase alphanumeric ASCII characters; make it short yet unambiguous) and add it to the list. That way, if your language is supported in a future release of GeSHiPygments, Rosetta Code can immediately benefit.
 
Also, if it hasn't been done yet, add the identifier to your language's category page. Use the "tags" parameter in the [[Template:Language|language template]] to specify it (e.g. "tags=foo" for the example above). If you find that your language already has a tag listed there that isn't in the Village Pump post, add it to the post as well.
 
If you'd like to, it's surprisinglynot easydifficult to write a new language definition for GeSHiPygments. See [[Rosetta Code:Village Pump/Syntax Highlighting#Relationship Between Rosetta Code and GeSHi|this post]] for more on the relationship between GeSHi and Rosetta Code. [httphttps://rosettacodepygments.org/geshidocs/lexerdevelopment/ AutoGeSHi]Write mayyour beown oflexer] use,for althoughmore iton isn'tadding nearlysupport asfor fancya asnew its name suggests; see [[Rosetta Code:AutoGeSHi|this page]]language.
 
<div style="background-color:#eee;padding:1em;>
'''''Note:''' There will likely be significant lag between a new lexer being added to Pygments, and the new syntax highlighting being available on Rosetta Code.''
 
''Once the new lexer is added to Pygments, it won't be available until Pygments has a release.''
 
''We would then need to wait for MediaWiki to bump the Pygments version in the package and release a new version.''
 
'''''Then''' we would need to wait for Miraheze to update to the version of MediaWiki software that includes the updated Pygments package.''
 
''A multiple month delay is expected, a several year delay is not out of the question.''</div>
 
===Recommended language tag usage===
Line 32 ⟶ 43:
 
In general, the language parameter should be the lowercase language name bounded by double quotes.
 
=== GeSHi extension self-report ===
Here is a list of the codes currently provided by GeSHi.
<div style="clear: both; column-count: 3; -webkit-column-count:3; -moz-column-count:3">
<lang list></lang>
</div>
10,327

edits