BBCode Syntax?

BBCode Syntax?

8
NewbieNewbie
8

    Nov 29, 2006#1

    Any chance anybody has created their own syntax highlighting code for BBCode?

    6,603548
    Grand MasterGrand Master
    6,603548

      Nov 29, 2006#2

      While writing on the Taglist file for BBCode I tried also to write a wordfile for BBCode. But I was forced to give it up because BBCode needs a mechanism which UltraEdit only supports for HTML.

      In HTML (HTML_LANG) < and </ and > are word delimiters but can be additionally also part of a word specification. This special handling would be also needed for [ and [/ and [ but is currently (UE v12.20a+4) not supported by UE/UES.
      Best regards from an UC/UE/UES for Windows user from Austria

      8
      NewbieNewbie
      8

        Nov 29, 2006#3

        I hate to hear such news but I appreciate the information. Many thanks.

        21
        Basic UserBasic User
        21

          BBCode Language Definition

          Sep 26, 2008#4

          Last time I checked (UltraEdit v10.20c) it was not really possible (and it's still problematic) to create a language entry for the meta HTML language many modern forums use, including this one, called BBcode. For those folks interested in syntax highlighting while editing offline in UE here is the entry wordfile.txt code:

          Code: Select all

          /L20"BBCode" EnableSpellasYouType Nocase String Chars = ` File Extensions = UBB
          /Delimiters = ~!@$%^&()_+=|\{}[]:;"'<> , .?
          /Indent Strings = ""
          /Unindent Strings = ""
          /Open Fold Strings = "[ CODE]" "[INDENT]" "[ LIST]" "[QUOTE]"
          /Close Fold Strings = "[ /CODE]" "[/INDENT]" "[ /LIST]" "[/QUOTE]"
          /C1"Tags code indent list quote"
          // /CODE /INDENT /LIST /QUOTE
          CODE
          INDENT
          LIST
          QUOTE
          [
          ]
          /C2"Tags color img size url"
          *
          // /COLOR /IMG /SIZE /URL
          COLOR
          IMG
          SIZE
          URL
          /C3"Operators and colors"
          =
          black
          blue
          green
          orange
          red
          /C4"Tags B I U"
          // /B /I /U
          B
          I
          U
          Note 1: The character on Delimiters line between , and . must be in wordfile a horizontal tab.

          Note 2: The space after [ on the lines with Open/Close Fold Strings on the CODE and LIST tags are just for not getting those BBCode tags parsed here as BBcode tags by this forum. In the wordfile those four spaces must not exist.

          Info:
          • Be sure to update the extension part (i.e. File Extensions = UBB) in the above /L definition. I name BBCode files .UBB for some historical reason (maybe "Ultra Bulletin Board", or something).
          • I spread out the color coding so that tags for indentation (code, indent, list, quote) have one color, special tags that should stand out (color, img, size, url) another color, and finally your standard text styles (bold, italics, underline) a third.
          • The block oriented tags (code, indent, list, quote) support folding.
          • In the /C3"Operators and colors" section you can explicitly name colors for highlighting if you like.
          • If you want you could auto-indent/unindent the block tags by replacing:

            Code: Select all

            /Indent Strings = ""
            /Unindent Strings = ""
            with

            Code: Select all

            /Indent Strings = "[ CODE]" "[INDENT]" "[ LIST]" "[QUOTE]"
            /Unindent Strings = "[ /CODE]" "[/INDENT]" "[ /LIST]" "[/QUOTE]"
            Note: The space after [ on CODE and LIST tags are just for not getting those BBCode tags parsed here as BBcode tags by this forum. In the wordfile those four spaces must not exist.

            Issue: The indentation will work, but not the un-indenting of e.g. [ /code]. I have no idea why that is. I personally do not use such indentation because the forums often force you to manually delete empty lines or indentations to actually properly space the content. And each forum seems to have its own set of inconsistent rules.
          • Alas convenient code like

            Code: Select all

            /Marker Characters = "[]"
            simply highlighting everything between any [ and ], i.e. the meta HTML tabs, is not allowed and does not work. But anyway I prefer to color code the specific tags by function (indentation, special, style).
          • To properly implement BBCode, UE would need to have a special language tag treating tags in [...] specially, i.e. like this is the case for HTML and <> using HTML_LANG.
          • There is another issue with String Chars = `. If you do not define a string delimiter (i.e. String Chars = ), the whole above highlighting will mess up. If you simply delete the parameter from the /L line, the default delimiters " and ' will be used.Is there actually a way to completely turn off String Chars =?

          6,603548
          Grand MasterGrand Master
          6,603548

            Re: BBCode Language Definition

            Sep 28, 2008#5

            Here are my suggestions:
            • Use Noquote instead of String Chars = ` to turn off syntax highlighting for strings.
               
            • Add to color group 2 the string /* as shown below:

              // /* /COLOR /IMG /SIZE /URL

              because forums using phpBB v3.0 and later use [ /*] (without space after [) in lists for the closing </li> element.
               
            • At color group 3 add the color names for all 16 VGA standard colors + orange specified in CSS 2.1:

              aqua
              black blue
              fuchsia
              gray green
              lime
              maroon
              navy
              olive orange
              purple
              red
              silver
              teal
              white
              yellow

               
            • I don't have problems with:

              /Indent Strings = "[ CODE]" "[ INDENT]" "[ LIST]" "[ QUOTE]"
              /Unindent Strings = "[ /CODE]" "[ /INDENT]" "[ /LIST]" "[ /QUOTE]"


              Note: Please ignore the space after each [ in the two lines above just added to avoid that those BBCode tags are parsed as BBCode tags by the forum.

              Indenting and un-indenting works perfect.
               
            • Do you know the BBCode tag list file I wrote and sent to IDM and which is online for download on user-submitted tag files and autocomplete files page?

              If you look into this file you will find some more common BBCode tags which should be highlighted also like the tags for a horizontal rule.

            21
            Basic UserBasic User
            21

              Re: BBCode Language Definition

              Sep 28, 2008#6

              Mofi,

              I integrated all your suggestions. Even though I have written several extensive forum FAQs (KotOR, KotOR II, Two Worlds etc.) your BBCode tag list contained quite a few tags I have never seen in modern forums. But I integrated them, just to be complete.

              BTW: And I figured out why the un-indenting did not work for me. It has to do with the way I type:
              1. [ ]
              2. LEFT ARROW
              3. /INDENT
              4. RIGHT ARROW
              5. RETURN
              But the un-indenting does not catch the definition on using this sequence.

              Here is v2.0 of the BBCode Language for the wordlfile.txt file:

              Code: Select all

              /L20"BBCode" EnableSpellasYouType Noquote Nocase File Extensions = UBB
              /Delimiters = ~!@$%^&()_+=|\{}[]:;"'<> , .?
              /Indent Strings = "[ALIGN]" "[ CODE]" "[INDENT]" "[ LIST]" "[PHP]" "[PRE]" "[QUOTE]"
              /Unindent Strings = "[/ALIGN]" "[ /CODE]" "[/INDENT]" "[ /LIST]" "[/PHP]" "[/PRE]" "[/QUOTE]"
              /Open Fold Strings = "[ALIGN]" "[ CODE]" "[INDENT]" "[ LIST]" "[PHP]" "[PRE]" "[QUOTE]"
              /Close Fold Strings = "[/ALIGN]" "[ /CODE]" "[/INDENT]" "[ /LIST]"  "[/PHP]" "[/PRE]" "[/QUOTE]"
              /C1"Blocks: code indent ..."
              // /ALIGN /CODE /INDENT /LIST /PHP /PRE /QUOTE
              ALIGN
              CODE
              INDENT
              LIST
              PHP
              PRE
              QUOTE
              [
              ]
              /C2"Special: color img ..."
              *
              // /* /COLOR /EMAIL /FLASH /FONT /HR /IMG /MARQ /SIZE /URL /VIDEO
              COLOR
              EMAIL
              FLASH
              FONT
              HR
              IMG
              MARQ
              SIZE
              URL
              VIDEO
              /C3"Operators: ="
              =
              /C4"Styles: b i sub sup u"
              // /B /I /SUB /SUP /U
              B
              I
              SUB
              SUP
              U
              /C5"Colors"
              aqua
              black blue brown
              cyan
              darkblue
              fuchsia
              gray green
              indigo
              lime
              maroon
              navy
              olive orange
              purple
              red
              silver
              teal
              violet
              white
              yellow
              /C6"Font Names"
              Arial
              Courier New
              Lucida Console
              System
              Tahoma
              Verdana
              /C7"Alignment: left ..."
              center
              down
              justify
              left
              right
              up
              /C8"Parameters: width ..."
              height
              width
              Note 1: The character on Delimiters line between , and . must be in wordfile a horizontal tab.

              Note 2: The space after [ on all CODE and LIST tags are just for not getting those BBCode tags parsed here as BBcode tags by this forum. In the wordfile those four spaces must not exist.

              Additional notes:
              • I added a few more color (/C) sections: Colors, Font Names, Alignment.
                 
              • The only thing that does not properly work is the highlighting of the font names with a space in them, i.e. "Courier New" and "Lucida Console". The first word is highlighted the second is not. One could probably *hack* this problem by adding two more lines with "New" and "Console".

                Test code:

                Code: Select all

                [font=Courier New] ... [/font]
                [font=Lucida Console] ... [/font]
                [font=Verdana] ... [/font]
                But is there a better way?
              Anyway thanks for the feedback it really helped a lot. The BBCode language should then almost be ready for upload to IDM.

              6,603548
              Grand MasterGrand Master
              6,603548

                Re: BBCode Language Definition

                Sep 29, 2008#7

                Well, if you run my macro SortLanguage from my SyntaxTools package you will see /C6 resorted to:

                Code: Select all

                /C6"Font Names"
                Arial
                Console Courier
                Lucida
                New
                System
                Tahoma
                Verdana
                This is what you have already indicated and what is definitely not the best solution, but the only one.

                The whole language definition for BBCode is not really good which is not your fault. As you have written in your first post and I have written also in my first post above a mechanism like HTML_LANG for elements starting with < or </ and ending with > would be required for BBCode tags starting with [ or [/ and ending with ]. Your current language definition works for the BBCode tags, but highlights also keywords outside []. You know that and I too, but this was the reason why I did not publish the language definition I had created once and later deleted. For those which often write BBCode in UltraEdit it is maybe better to have a syntax highlighting for the tags with the disadvantage of some wrong highlighted words than no highlighting. But I publish only syntax highlighting definitions which do not highlight many words wrong.
                Best regards from an UC/UE/UES for Windows user from Austria

                21
                Basic UserBasic User
                21

                  Re: BBCode Language Definition

                  Sep 29, 2008#8

                  Sometimes I really wish there was a "dummy" mode for the syntax highlighting that would let you define words, e.g. in quotes like "Courier New", without having delimiters or other distractions mess into things, i.e. simply highlight those words as they are. Sigh.

                  I have the same problem in the language definition for D. There I'd like to "simply" have the library calls highlighted, e.g. "tango.core.", but since "." is a delimiter this does not work. Removing the delimiter "." on the other hand would no longer let the code recognize other key words delimited by "." e.g. ".length".

                  Strange that such a "verbatim highlight mode" has not been integrated.

                  236
                  MasterMaster
                  236

                    Sep 29, 2008#9

                    As already discussed elsewhere, there is a tradeoff between performance, comprehensiveness and correctness of syntax highlighting. UE's developers chose a way that allows for fast and thorough highlighting in most cases - with several shortcomings in special circumstances like you describe. Other editors that favor a regex-based approach are much more flexible and can (theoretically) deliver near-perfect highlighting, but at a performance price.

                    As you probably know, you can define ".core" as well as "tango", so both will be highlighted. You could even still detect typos like tanggo.core - but you'd miss methods bound to wrong (but otherwise legal) objects. That doesn't look like so much of a problem.

                    21
                    Basic UserBasic User
                    21

                      Sep 29, 2008#10

                      pietzcker wrote:As you probably know, you can define ".core" as well as "tango", so both will be highlighted. You could even still detect typos like tanggo.core - but you'd miss methods bound to wrong (but otherwise legal) objects. That doesn't look like so much of a problem.
                      I was doing that. And in the above case it would work well enough, it gets ugly when you have something like "std.c.something", the "c" would then be too "vague".

                      Oh well, I'm happy we have syntax highlighting at all. :)