1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

GeSHi Syntax Highlighter

Discussion in 'Add-on Releases [Archive]' started by digitalpoint, Oct 21, 2011.

Thread Status:
Not open for further replies.
  1. digitalpoint

    digitalpoint Well-Known Member

    About
    This is a GeSHi based syntax highlighter that intercepts CODE, HTML and PHP BBCode and formats them to be "pretty".

    Installation
    • Put the contents of the library directory into your XenForo library directory.
    • Install the addon-dpSyntaxHighlighter.xml file in your Admin Control Panel -> Install Add-on option.
    Usage
    • For PHP and HTML highlighting, nothing special is needed, just use the normal [php] and [html] BBCode.
    • If you want to specify a specific language to highlight, you can use the [code] BBCode with an option like so: [code=javascript]
    Notes
    • All languages that GeSHi supports are supported (currently 201).
    • There is one option that is added to the "Messages" section of XenForo options. (Show Line Numbers In Parsed BBCode)
    geshi.png
     

    Attached Files:

    siduko, jmurrayhead, Daracon and 16 others like this.
  2. Andy.N

    Andy.N Well-Known Member

    Finally!!!
    Thanks Shawn.
     
  3. ShadyX

    ShadyX Well-Known Member

    This is a wonderful addon, Thanks very much Shawn :)
     
  4. M@rc

    M@rc Well-Known Member

    Love the add-on. Thanks!
     
  5. EQnoble

    EQnoble Well-Known Member

    Ohhh nice!!! All shiny and stuff...and still has that new mod smell. :)

    Im'a try it out today.

    Thanks for this...can't wait to play around with it :)
     
  6. digitalpoint

    digitalpoint Well-Known Member

    There isn't a lot to "play around" with really... just the one setting if you do/don't want line numbers. :)
     
    EQnoble likes this.
  7. EQnoble

    EQnoble Well-Known Member

    Nice!

    Is that an option by chance or a manual edit (to the mods files I would have to assume)?
     
  8. digitalpoint

    digitalpoint Well-Known Member

    Option... see first post for location.
     
    EQnoble likes this.
  9. bousaid

    bousaid Well-Known Member

    wonderful addon .. (y)
     
  10. EQnoble

    EQnoble Well-Known Member

    And that would be me blissfully being ignorant while missing the notes section of the OP where it clearly defines it as being in the Messages Section :) Oops!
     
  11. Andy.N

    Andy.N Well-Known Member

    What is the penalty on post loading time? Would this affect all pages or only pages with this bbcode?
     
  12. digitalpoint

    digitalpoint Well-Known Member

    It will only run the GeSHi code/class when there is actual PHP, CODE or HTML BBCode that need to be parsed. If a page has none if it, it should not affect page generation time. If it does, then obviously there will be a little overhead for it since it needs to parse/process it. It would be nice if XF stored pre-parsed posts (then it would just have to parse the post once, and be done with it), but currently they do not. I already made a feature request for storing parsed posts over here.
     
    lasertits and Andy.N like this.
  13. Mikey

    Mikey Well-Known Member

    Unless I'm mistaken, XenForo already highlights code?

    Nice add-on though, thanks :)
     
  14. Digital Doctor

    Digital Doctor Well-Known Member

    Code Test:
    PHP:
    if (var == true)
    {
        
    document.write('hello world');
    }
    >>>>formats them to be "pretty" <<<
    Define pretty.
    xF seems to natively colo(u)rize.
     
  15. Floris

    Floris Guest

    Not for everything, nor does it have line numbering for example. This just extends on what xenforo already does.

    Great stuff DigitalPoint
     
  16. Sadik B

    Sadik B Well-Known Member

    Excellent Shawn! Thanks... This is one of two things I needed to convert to XF. I was really very very reluctant (as always) to code this myself... :)

    Thanks again! (y)

    To the guy who was saying XF already has pretty code, XF doesn't support all languages. I need this specifically for SQL, as I run an Oracle Forum... I have customized the old code highlighting addon on VB to have an editor button like PHP and HTML here called SQL where you can select the code and press the SQL button for SQL highlighting with [SQL] [/SQL]. I will be doing the same for this one for XF! Now if only Kier would release that magical Resource Manager which I plan to use as a Downloads addon, I could quickly migrate... :D
     
  17. Andy.N

    Andy.N Well-Known Member

    Shawn,
    Can this addon be modified so that the code button in XF editor has the additional languages added to its dropdown list. Right now, it has General code, PHP and HTML. Would be nice if we can arrange the order of this list so the languages most used at our own forum are on top.
     
  18. digitalpoint

    digitalpoint Well-Known Member

    Probably wouldn't be too difficult, but I think you then risk making it cluttered and less usable if you have 201 languages in the drop-down list.
     
  19. digitalpoint

    digitalpoint Well-Known Member

    If you want to add additional languages you pick to the dialog, you need to make 2 changes... First you would need to edit the js/tinymce/themes/xenforo/js/code.js file and change this:
    Code:
    default:     tag = 'CODE';
    to this:
    Code:
    default:     tag = $('#ctrl_type').val();
    Unfortunately there's not a way around the JavaScript file edit...

    The other change would be to edit the editor_dialog_code template to add whatever specific languages you want to the <select> element. For example:

    Code:
    <option value="code=javascript">JavaScript</option>
    <option value="code=ruby">Ruby</option>
    <option value="code=sql">SQL</option>
    etc...
     
    EQnoble and Andy.N like this.
  20. Andy.N

    Andy.N Well-Known Member

    Ideally, the list of language will be in the ACP Options where it has a textbox and you can enter things like
    And the dropdown will show those in that exact order.

    EDIT: Got ninja'd by Shawn why I was typing.
     
Thread Status:
Not open for further replies.

Share This Page