Difference between revisions of "Code highlighting"

From Second Life Wiki
Jump to navigation Jump to search
m (yep chrome works how i expected)
 
(9 intermediate revisions by 2 users not shown)
Line 2: Line 2:
== wiki.secondlife.com ==
== wiki.secondlife.com ==


If you're creating pages on this wiki using code examples, it's highly useful to embed the code between tags that retain formatting and other desirable attributes. Tags can also colorize syntax.
If you're creating pages on this wiki that include external code examples (like LSL or HTML), it's '''highly useful to enclose the code between tags that retain formatting''' and other desirable attributes, like colorized syntax.
 
This is basically done by enclosing the code within the HTML tags. (See the Examples pages below.)


=== Tags ===
=== Tags ===
Line 10: Line 8:
These tags are actively being used.
These tags are actively being used.


* <code>'''<nowiki><tt></nowiki>'''</code> - Fixed-width text. Used in general-purpose scenarios, and when others are too restricting for whatever reason.
* <code>'''<nowiki><tt></nowiki>'''</code> - Fixed-width text. Used in generic scenarios, and when others are too restricting for whatever reason.
* <code>'''<nowiki><lsl></nowiki>'''</code> - Widely used on the [[LSL Portal]] and other scripts that appear on-wiki.
* <code>'''<nowiki><lsl></nowiki>'''</code> - Widely used on the [[LSL Portal]] and other LSL scripts that appear on-wiki.
* <code>'''<nowiki><htmlstrict4></nowiki>'''</code> - Use it when you need to highlight HTML code snippets, such as for use with Shared Media.
* <code>'''<nowiki><html4strict></nowiki>'''</code> - Use this when you need to highlight HTML code snippets, such as for use with Shared Media.
* <code>'''<nowiki><code></nowiki>'''</code> - Used not just for simpler, single-line code, but user input that needs highlighting, [[Style_Guide#Files.2C_paths.2C_URLs.2C_code.2C_and_other_typed_user_input|as described in the Knowledge Base Style Guide]].
* <code>'''<nowiki><code></nowiki>'''</code> - Used not just for simpler, single-line code, but user input that needs highlighting, [[Style_Guide#Files.2C_paths.2C_URLs.2C_code.2C_and_other_typed_user_input|as described in the Knowledge Base Style Guide]].


Line 21: Line 19:
These pages use code highlighting tags extensively.
These pages use code highlighting tags extensively.


* '''[[:Category:LSL Library]]''' - Click a script to see how it appears with the <code><nowiki><lsl></nowiki></code> tag.
* '''[[:Category:LSL Library]]''' - Click a script page to see how it appears with the <code><nowiki><lsl></nowiki></code> tag.
* '''[[User:Becky_Pippen/Shared_Media_LSL_Recipes|Shared Media LSL Recipes]]''' - Becky Pippen mentioned a limitation of the <code><nowiki><lsl></nowiki></code> tags: namely, you seemingly can't highlight code inside, so she's using <code><nowiki><tt></nowiki></code> instead.
* '''[[User:Becky_Pippen/Shared_Media_LSL_Recipes|Shared Media LSL Recipes]]''' - Becky Pippen mentioned a limitation of the <code><nowiki><lsl></nowiki></code> tags: namely, you seemingly can't highlight code inside, so she's using <code><nowiki><tt></nowiki></code> instead.
* '''[[Shared Media wrapper]]''' - Torley Linden learned from Khepri Contractor that the <code><nowiki><html4strict></nowiki></code> tag works.
* '''[[Shared Media wrapper]]''' - Torley Linden learned from Khepri Contractor that the <code><nowiki><html4strict></nowiki></code> tag works.


== blogs.secondlife.com ==
== community.secondlife.com ==
 
While not as precise as the wiki, code can be called out on the forums and blogs, too. This is especially useful in the Scripting and Scripting Library forums where LSL scripts are shared.


When creating a post, from the editing toolbar, choose '''>>''' > '''Syntax Highlighting''' > '''Plain'''.
When creating a post, from the editing toolbar, click [[File:Insertcode.gif|link=]], then paste in your script.


[[File:Syntax_Highlighting_-_Plain.png]]
Users of Firefox (with Greasemonkey installed) and Google Chrome can install [http://userscripts.org/scripts/show/101223 LSL posting tool for community.secondlife.com] created by [[User:Cerise Resident|Cerise]] to get LSL highlighting on the forums. This is especially useful in the [http://community.secondlife.com/t5/LSL-Scripting/bd-p/LSLScripting Scripting] and [http://community.secondlife.com/t5/LSL-Scripting-Library/bd-p/LSLScriptingLibrary Scripting Library] forums where LSL scripts are shared.


This doesn't colorize code but it does isolate it and preserves line breaks.
To use the highlighter, paste in your script with the [[File:Insertcode.gif|link=]] button as usual, then press the {{K|+ LSL}} button to highlight. Use {{K|- LSL}} if you want to remove the highlights.

Latest revision as of 23:01, 21 April 2011

wiki.secondlife.com

If you're creating pages on this wiki that include external code examples (like LSL or HTML), it's highly useful to enclose the code between tags that retain formatting and other desirable attributes, like colorized syntax.

Tags

These tags are actively being used.

  • <tt> - Fixed-width text. Used in generic scenarios, and when others are too restricting for whatever reason.
  • <lsl> - Widely used on the LSL Portal and other LSL scripts that appear on-wiki.
  • <html4strict> - Use this when you need to highlight HTML code snippets, such as for use with Shared Media.
  • <code> - Used not just for simpler, single-line code, but user input that needs highlighting, as described in the Knowledge Base Style Guide.

For more tags, see the Parser extension tags on Special:Version. Some tags are possible because of GeSHiHighlight.

Examples

These pages use code highlighting tags extensively.

  • Category:LSL Library - Click a script page to see how it appears with the <lsl> tag.
  • Shared Media LSL Recipes - Becky Pippen mentioned a limitation of the <lsl> tags: namely, you seemingly can't highlight code inside, so she's using <tt> instead.
  • Shared Media wrapper - Torley Linden learned from Khepri Contractor that the <html4strict> tag works.

community.secondlife.com

When creating a post, from the editing toolbar, click Insertcode.gif, then paste in your script.

Users of Firefox (with Greasemonkey installed) and Google Chrome can install LSL posting tool for community.secondlife.com created by Cerise to get LSL highlighting on the forums. This is especially useful in the Scripting and Scripting Library forums where LSL scripts are shared.

To use the highlighter, paste in your script with the Insertcode.gif button as usual, then press the + LSL button to highlight. Use - LSL if you want to remove the highlights.