facelessuser / BracketHighlighter

Bracket and tag highlighter for Sublime Text
https://facelessuser.github.io/BracketHighlighter/
1.74k stars 245 forks source link

error with custom syntax #376

Closed eparisio closed 7 years ago

eparisio commented 7 years ago

Requirements

Do not delete this. Template must be followed or the issue will be marked Invalid and closed.

Please mark if you have done done this. Mark by placing an x in the box: - [ ] -> - [x]. Support will not be offered without this.

For bugs, provide errors from console, examples etc. For feature requests, describe the desired feature. Be as detailed as possible. Vague issues/requests will be marked with Insufficient Details for about a week. If not corrected, they will be marked Stale for about a week and then closed.


Issue Support Info

i have a custom syntax on my jsp/tag files for jstl language.

the plugin crash with the following error when he try to render the brackets on custom elements/tag (jstl syntax definitions), on javacript and html and internal brackets [{"(' parts works all fine without errors.

BracketHighlighter: Plugin Post Match Error: Traceback (most recent call last): File "bh_core in C:\Sublime Text 3\Data\Installed Packages\BracketHighlighter.sublime-package", line 335, in post_match File "bh_modules.tags", line 91, in post_match AttributeError: 'str' object has no attribute 'get' Traceback (most recent call last): File "bh_core in C:\Sublime Text 3\Data\Installed Packages\BracketHighlighter.sublime-package", line 1270, in payload File "bh_core in C:\Sublime Text 3\Data\Installed Packages\BracketHighlighter.sublime-package", line 437, in match File "bh_core in C:\Sublime Text 3\Data\Installed Packages\BracketHighlighter.sublime-package", line 515, in find_matches File "bh_core in C:\Sublime Text 3\Data\Installed Packages\BracketHighlighter.sublime-package", line 224, in highlighting File "bh_modules.tags", line 64, in highlighting AttributeError: 'str' object has no attribute 'get'

there an example of code(jsp) that brokes up:

<!-- this custom tags breaks -->
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="cms" uri="http://site.com/tld/cmstags" %>
<%@ taglib prefix="common" tagdir="/WEB-INF/tags/desktop/common" %>
<%-- <c:url value="/contactus" var="contactUsUrl" /> --%>
<common:utils />
<cms:pageSlot position="contactusSubtitle" var="feature">
                 <!-- on {} and "" works fine -->
        <cms:component component="${feature}" />
</cms:pageSlot>

<!-- there works fine -->
<script>
    $(document).ready(function() {
        });
</script>
<!-- this html tags breaks -->
<div id="contactUsPopupOnProd" class="contactUs" >
    <div class="contactus-subtitle-message">
           text
        </div>
</div>

i add JSTL i my config file:

"tag_mode": { "html": ["HTML", "HTML 5", "PHP", "HTML (Jinja Templates)", "HTML (Rails)", "HTML (Twig)", "laravel-blade", "JSTL"], ... }

and:

"brackets": [ { "name": "angle", ... "language_list": [ ... "JSTL" ], ... },

that should make it works on jsp/tag files (included syntax and my custom).

it is something on language definition that go in conflict with your plugin probably. I see that even with the st3 included syntax definition for jsp [Java servlet page (JSP)] don't works on custom tags. Even with base configuration (not adding jstl reference to the different options) it breaks (included syntax and my custom).

Before the update it works fine, so i think it's something post update.

Can you check this problem? and if you find what is going in conflict, and depends on language syntax, can you explain so i can try to fix it and give an updated version to the others thousands of peoples that use it too.


EDIT:

the problem is extended on every tag types, even in HTML language give the same error when trying to create tag brackets (angle, <div></div>)

thanks a lot.

facelessuser commented 7 years ago
  1. JSTL should be lower case as the actual tmLanguage file name is jstl not JSTL. It is possible I lowercase everything in the check, but in general, you should use the same case that the file name uses, not what shows up in the bottom right hand corner of Sublime.
  2. I see nothing wrong with how it currently works on the latest Sublime with the latest BH. If you are expecting BH to be aware of custom tags, then I am sorry to tell you, it won't be. It is setup to handle HTML, XML, and currently Cold Fusion. If you want custom tag support for jsp, you will need to add a new profile.

You will need to create a profile for jsp in bh_tag.sublime-settings, and then add the proper search patterns for opening self_closing_patterns, single_tag_patterns, tag_name, attributes, start_tag, end_tag, etc. Take a look at bh_tag.sublime-settings, and take a look at the documentation to see how to add your own custom tag profile. If you plan to only do this locally on your machine, you can edit the existing HTML profile, but in general, I would recommend creating a separate profile for jsp.

eparisio commented 7 years ago

Hi, thanks a lot for the answer, i will do the necessary edits.

i will awaits for the second problem answer, about the error that occours even in normal html file with a clean installation, so not only in my syntax but even on standard html and jsp language.

if you need more info, in case you can't replicate, i can make some other tests to find if is caused by some other plugin installed.

facelessuser commented 7 years ago

I am not seeing the errors you are describing. I am on the latest dev build 3125 which is equivalent to the latest beta build 3126. I would try uninstalling BH and reinstalling (make sure to restart after installing BH). If you are having issues still, you can try disabling other 3rd party plugins to see if they are interfering (restart afterwards). As a last ditch effort, you can revert your Sublime install: https://www.sublimetext.com/docs/3/revert.html.

There is nothing inherently wrong with BH as it is working for me on Windows, Linux, and Mac. Also, there are a lot of people using the latest ST3 with the latest BH, and you are the only one with this issue. All signs point to something odd with your specific install. Maybe something got corrupt, I'm not sure, but I can't reproduce your issue. As far as I can see, there are no other issues with BH.

eparisio commented 7 years ago

Ok, thanks. i made some edits a deactivate some plugin and seems to works again, probably it's a conflict with some other ones.