Syntax (XML service)

    Table of contents
    No headers

    To test/debug the syntax service, do the following:

    Get syntax.xml and brush files from svn

    cd /var/www/dekiwiki/skins
    svn co https://svn.mindtouch.com/source/public/dekiwiki/trunk/src/services/Scripts/res/syntax/
    cd syntax
    svn cat https://svn.mindtouch.com/source/public/dekiwiki/trunk/src/services/Scripts/syntax.xml > syntax.xml
    

    Go to your control panel and add the service like so:

     syntax.png

     

     Then add your Brush file to the /var/www/dekiwiki/skins/syntax/ directory and modify the syntax.xml file.  For example to add the powershell brush add this function to syntax.xml

      <function transform="pre">
        <name>Powershell</name>
        <description>Highlight Powershell syntax</description>
        <param name="code" type="str">source code to highlight</param>
        <param name="collapse" type="bool" optional="true">collapse code view (default: false)</param>
        <param name="firstline" type="num" optional="true">first line number (default: 1)</param>
        <return>
          <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
            <head block="var baseUri = config['resources-uri'] ?? 'http://scripts.mindtouch.com/res/syntax'">
                  <link type="text/css" rel="stylesheet" eval:href="uri.appendpath(baseUri, 'SyntaxHighlighter.css')" />
                  <script type="text/javascript" eval:src="uri.appendpath(baseUri, 'shCore.js')" />
                  <script type="text/javascript" eval:src="uri.appendpath(baseUri, 'shBrushPowershell.js')" />
            </head>
            <body>
              <pre name="code" eval:class="'powershell' .. (args.collapse == 'true' ? ':collapse' : '') .. (args.firstline ? ':firstline[' .. args.firstline .. ']' : '');"><eval:expr value="args.code"/></pre>
            </body>
            <tail>
              <script type="text/javascript">dp.SyntaxHighlighter.HighlightAll('code');</script>
            </tail>
          </html>
        </return>
      </function>
    
    

    Invoke the service by adding a "Formatted" text block, then paste in your code, then select the Transformations drop down and choose the highlighter you want to use

     

     

     

     

    Tag page

    Files 1

    FileVersionSizeModified 
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by