Sublime Forum

BracketHighlighter

#201

With the current way BH is implemented, it will be very difficult to handle these cases. BH uses regex to find the html tags. Now you (or someone else) are inserting more tags inside the tags attribute area. It should be very clear why this breaks detection. At one point, I tried to use scope extent to effectively get the range of a tag, but that proved fruitless due to the way HTML is scoped. The problem you are experiencing is not an uncommon one. When people do similar things in other languages (like PHP) you can get the same effect.

Since BH is a very generalized bracket matching engine, it doesn’t have the needed complexity to handle these kinds of language specific issues at this time. Certain scenarios will stress it beyond the point where it can effectively highlight; I won’t go into all of them here though. Maybe in the future if the engine was redesigned to provide more hooks or to approach finding the brackets differently, these kinds of problems could be worked around, but I imagine there would need to be significant changes to how BH approaches finding brackets to have any hope of handling these types of problems. Also, keep in mind, BH is an unfunded plugin despite its massive user base; I can count on one hand the number of people who ever have donated to it, so I am not itching to overhaul the entire framework as it is my free time that goes into development.

Also, I don’t use vBulletin, so I have no interest in spending time on improving vBulletin support. Now that might sound harsh, but remember it is my free time that goes into improvements of not just this plugin, but many others as well. I don’t have time to learn the ins and outs of every language that people use. I provide a core, and I provide personal support for languages I have a vested interest in, but support for other languages, I leave up to the community to figure out. I do take input on how the core could be improved to accommodate other languages, and I also accept pull requests.

1 Like

#202

I would say one more thing. I don’t know how vBulletin is used, so it is possible that you could adjust the regex for tags and it get it working as traditional cases of nesting vb tags inside other tags may not be that bad (again, I don’t use vb tags, so I don’t know). If the regex is solid enough I would accept a pull request. I am not going to spend time on it personally though as I don’t use vBulletin.

0 Likes

#203

Thanks!
Please “direct me” where I need to change regex?
As I understand, I must create new regex in: bh_core.sublime-settings - user with follow structure:

"brackets": // NewHTML { "name": "html", "open": "(<)(?=\\w\\:\\-]+(?:(?:\\s+\\w\\-:]+(?:\\s*=\\s*(?:\"^\"]*\"|'^']*'|^>\\s]+))?)*)\\s*\\/?>|\\/\\w\\:\\-]+^>]*>)", "close": "(?<=<)(?:\\w\\:\\-]+(?:(?:\\s+\\w\\-:]+(?:\\s*=\\s*(?:\"^\"]*\"|'^']*'|^>\\s]+))?)*)\\s*\\/?|\\/\\w\\:\\-]+^>]*)(>)", "style": "tag", "scope_exclude": "string", "comment"], "language_filter": "whitelist", "language_list": "HTML", "HTML 5", "XML", "PHP", "Handlebars"], "plugin_library": "bh_modules.tags", "find_in_sub_search": "only", "enabled": false }, ]
and try to change strings:
“open”: ***********
“close”: ***********

??

0 Likes

#204

[quote=“taravasya”]Thanks!
Please “direct me” where I need to change regex?
As I understand, I must create new regex in: bh_core.sublime-settings - user with follow structure:

"brackets": // NewHTML { "name": "html", "open": "(<)(?=\\w\\:\\-]+(?:(?:\\s+\\w\\-:]+(?:\\s*=\\s*(?:\"^\"]*\"|'^']*'|^>\\s]+))?)*)\\s*\\/?>|\\/\\w\\:\\-]+^>]*>)", "close": "(?<=<)(?:\\w\\:\\-]+(?:(?:\\s+\\w\\-:]+(?:\\s*=\\s*(?:\"^\"]*\"|'^']*'|^>\\s]+))?)*)\\s*\\/?|\\/\\w\\:\\-]+^>]*)(>)", "style": "tag", "scope_exclude": "string", "comment"], "language_filter": "whitelist", "language_list": "HTML", "HTML 5", "XML", "PHP", "Handlebars"], "plugin_library": "bh_modules.tags", "find_in_sub_search": "only", "enabled": false }, ]
and try to change strings:
“open”: ***********
“close”: ***********

??[/quote]

No, I that rule is disabled and was more an experiment that I should probably remove. Tags are actually triggered off the angle bracket rule and then fed through a bh_plugin called tags: github.com/facelessuser/Bracket … ags.py#L10. The regex for determining HTML tags is found there.

0 Likes

#205

Hi I am trying to style the colour of brackets using the following config in ST3 (latest build 3083 64 bit) and it doesn’t seem to work, everything remains white in colour:

bh_core.sublime-settings - user settings:

{
    "bracket_styles": {
        // This particular style is used to highlight
        // unmatched bracket pairs. It is a special
        // style.
        "unmatched": {
            "icon": "question",
            "color": "brackethighlighter.unmatched",
            "style": "highlight"
        },
        // User defined region styles
        "curly": {
            "icon": "curly_bracket",
            "color": "brackethighlighter.curly",
            "style": "highlight"
        },
        "round": {
            "icon": "round_bracket",
            "color": "brackethighlighter.round",
            "style": "outline"
        },
        "square": {
            "icon": "square_bracket",
            "color": "brackethighlighter.square",
            "style": "outline"
        },
        "angle": {
            "icon": "angle_bracket",
            "color": "brackethighlighter.angle",
            "style": "outline"
        },
        "tag": {
            "icon": "tag",
            "color": "brackethighlighter.tag",
            "style": "outline"
        },
        "single_quote": {
            "icon": "single_quote",
            "color": "brackethighlighter.quote",
            "style": "outline"
        },
        "double_quote": {
            "icon": "double_quote",
            "color": "brackethighlighter.quote",
            "style": "outline"
        },
        "regex": {
            "icon": "regex",
            "color": "brackethighlighter.quote",
            "style": "outline"
        }
    }
}

And in my Widget - SoDaReloaded.stTheme file:

<!-- BEGIN Bracket Highlighter plugin color modifications -->

<dict>
    <key>name</key>
    <string>Unmatched</string>
    <key>scope</key>
    <string>brackethighlighter.unmatched</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#FD971F</string>
    </dict>
</dict>

<dict>
    <key>name</key>
    <string>Bracket Curly</string>
    <key>scope</key>
    <string>brackethighlighter.curly</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#FF0000</string>
    </dict>
</dict>

<dict>
    <key>name</key>
    <string>Bracket Round</string>
    <key>scope</key>
    <string>brackethighlighter.round</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#0000FF</string>
    </dict>
</dict>

<dict>
    <key>name</key>
    <string>Bracket Square</string>
    <key>scope</key>
    <string>brackethighlighter.square</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#800080</string>
    </dict>
</dict>

<dict>
    <key>name</key>
    <string>Bracket Angle</string>
    <key>scope</key>
    <string>brackethighlighter.angle</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#AE81FF</string>
    </dict>
</dict>

<dict>
    <key>name</key>
    <string>Bracket Tag</string>
    <key>scope</key>
    <string>brackethighlighter.tag</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#FD971F</string>
    </dict>
</dict>

<dict>
    <key>name</key>
    <string>Single Quote | Double Quote | Regex</string>
    <key>scope</key>
    <string>brackethighlighter.quote</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#AE81FF</string>
    </dict>
</dict>

<!-- END Bracket Highlighter plugin color modifications -->

Installed packages are:

“AdvancedNewFile”,
“Alignment”,
“AlignTab”,
“All Autocomplete”,
“AutoFileName”,
“BracketHighlighter”,
“Brackets Color Scheme”,
“BufferScroll”,
“Can I Use”,
“Color Highlighter”,
“ColorPicker”,
“CSS Extended Completions”,
“CSS Unminifier”,
“DocBlockr”,
“EasyMotion”,
“Emmet”,
“FileDiffs”,
“FindKeyConflicts”,
“FTPSync”,
“Git”,
“GitGutter”,
“Grunt”,
“Grunt Snippets”,
“Gulp”,
“HTML Minifier”,
“HTML-CSS-JS Prettify”,
“HTML5”,
“JavaScript & NodeJS Snippets”,
“JavaScript Snippets”,
“JavaScript Ultimate”,
“jQuery”,
“JsFormat”,
“JSHint”,
“LESS”,
“Less2Css”,
“MaxPane”,
“Minifier”,
“My Snippets”,
“Open URL”,
“Origami”,
“Package Control”,
“PackageResourceViewer”,
“Pretty JSON”,
“Sass”,
“SassBeautify”,
“SCSS”,
“SCSS Snippets”,
“SideBarEnhancements”,
“SublimeCodeIntel”,
“SublimeLinter”,
“SublimeLinter-contrib-scss-lint”,
“SublimeLinter-csslint”,
“SublimeLinter-html-tidy”,
“SublimeLinter-jshint”,
“SublimeLinter-json”,
“SublimeLinter-php”,
“SublimeLinter-xmllint”,
“SublimeOnSaveBuild”,
“Syntax Highlighting for Sass”,
“Theme - Soda”,
“Theme - SoDaReloaded”,
“Trimmer”,
“VBScript”,
“Web Inspector”

Can anyone see anything wrong here?? Help please!

0 Likes

#206

You aren’t supposed to edit the widget themes. Those only work in on things like search input boxes etc. not your actual file view. Widget themes often aren’t even full theme since they don’t have to support different languages. They usually just support coloring regex and selections. You need to add your bracket highlighter colors to the theme used in your file views.

0 Likes

#207

Ah ok thank you for the swift reply. I thought it might be something to do with the theme.

Do you know how I can locate the theme which is being used for my file views?

0 Likes