MindTouch Developer Center > Deki > FAQ > Page Management > How do I...Display syntax highlighting?

How do I...Display syntax highlighting?

Table of contents
No headers

 The Deki Wiki syntax extension provides built-in support for highlighting syntax of popular programming languages.  This extension is based on the work done by Alex Gorbatchev on the syntaxhighlighter project. To use it:

  1. Enable the syntax extension using these instructions.
  2. Open the affected page in the editor.
  3. Set Style to Formatted.

  4. SyntaxHighlighting1.PNG
    Figure 1

  5. Enter the content to which you want to apply syntax highlighting.
  6. SyntaxHighlighting2.PNG
    Figure 2

  7. Select the content, click Transform Content, and choose a language.
  8. SyntaxHighlighting3.PNG
    Figure 3

  9. Save the page.

Note that it is also possible to use syntax highlighting on file data, rather than page content.  To do this, pass the output of web.text to the syntax extension:


Output

To display the formatted contents of an XML file:

{{ syntax.xml(web.text("http://scripts.mindtouch.com/scratch.xml")) }}

<extension>
  <title>Scratch Extension</title>
  <label>Scratch</label>
  <copyright>Copyright (c) 2007, 2008 MindTouch, Inc.</copyright>
  <description>This extension contains functions for embedding Scratch applications.</description>
  <uri.help>http://wiki.developer.mindtouch.com/MindTouch_Deki/Extensions/Scratch</uri.help>
  <uri.logo>http://scripts.mindtouch.com/logos/scratch-logo.png</uri.logo>

  <function>
    <name>scratch</name>
    <description>Embed a Scratch application.</description>
    <param name="id" type="str">Application User/ID.</param>
    <param name="width" type="num" optional="true">Application width. (default: 482)</param>
    <param name="height" type="num" optional="true">Application height. (default: 387)</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <body>
          <applet id="ProjectApplet" style="display:block" code="ScratchApplet" codebase="http://scratch.mit.edu/static/misc" archive="ScratchApplet.jar" eval:width="web.size(args.width ?? 482)" eval:height="web.size(args.height ?? 387)">
            <param name="project" eval:value="'../../static/projects/' .. args.id .. '.sb'" />
          </applet>
          <a eval:href="'http://scratch.mit.edu/projects/' .. args.id">Learn more about this project</a>
        </body>
      </html>
    </return>
  </function>
</extension>

Tag page
Viewing 1 of 1 comments: view all
How do you add other features (like collapse) using this method?
Posted 02:16, 6 May 2008
Viewing 1 of 1 comments: view all
You must login to post a comment.
Powered by MindTouch Deki v.8.08.2