Forum Discussion

SeanH's avatar
SeanH
Guide
11 years ago

Is there an option to use markdown syntax or any options for enhanced code syntax highlighting?

Is there an option to use markdown syntax or any options for enhanced code syntax highlighting? This is in addition to the basic option in the html editor to highlight code.
  • samudhraa's avatar
    samudhraa
    11 years ago

    Hi ,

     

    Just a suggestion. One of the reasons for the time taken for page load , could be because you are including the library on load , inside the if condition.

    Instead , if you could include the file at the header (<script src="pretty.js">) , and add the class after checking the pagename , that might save some time in page load.

     

    Thanks for the idea though.

     

    Thanks,

    Sam

  • AdamN's avatar
    AdamN
    11 years ago

    Hi iftomkins,

     

    According to the Prettify documentation, there is an autoload parameter you can set to false when loading the script file. You can then call "prettyPrint()" later to do the syntax highlighting. This should allow you to pre-load the script and then run the highlighting after the content has loaded and you've applied the "prettyprint" class.

     

    See the Auto-Loader and Serving your own JS & CSS sections of their documentation for more information.

     

    I hope this helps!

  • iftomkins's avatar
    iftomkins
    11 years ago

    UPDATE: Turns out I could not get this to work via Google's CDN. The prettyPrint() function gave an "undefined" error. To fix it, I downloaded the files, and emailed them to Lithium support to upload them to our assets library, and then loaded the normal prettify.js file in the <head>, instead of prettify_run.js.

     

    In the head section: 

    <script type="text/javascript" src="/html/assets/prettify.js"></script>

     In the hitbox section: 

     <#if page.name?lower_case == "forumtopicpage" || page.name?lower_case == "replypage">
    jQuery("#lia-body .lia-content .lia-message-body-content pre").addClass('prettyprint');
    prettyPrint();
    </#if>