Sublime Forum

How to add specific tags to the inline tags list (close_tag)?

#1

Hello,

Sorry for my broken english, i try my best.
We are finishing adding XPX language to Sublime Text control package.

The XPX language, like HTML language, owns a list of inline tags (like img in HTML).
Examples of XPX block tags : , , , , …
Examples of XPX inline tags : , , , …

I’d been looking for a week how to declare my inline tags in the exception list of close_tag function to prevent close_tag to close the tag as a block tag (get the previous tag).

I read many times html_completions.py but no trace to help me. I’ve tried many of tests non success.

I suppose that when close_tag is called, it refers to a list of inline tags.
How can i complete this list for my context (text.html.xpx) with my inline tags list ?

I tried also many commands to prevent close_tag to run but nothing run correctly.

Thank’s for your help.
Sincerely yours.
P. Milon

0 Likes

#2

this is an interesting question - I also had to explore how this works recently, which was not easy as it is a closed source command.
But I discovered that it works on the scopes assigned to the open tag - specifically, whether it has a / before the > scoped as punctuation.definition.tag.end

However, this obviously only helps if the self closing tags are well formed, i.e. XML style <example /> instead of old fashioned HTML tag soup style <example> - it wouldn’t work without the /> ending - I don’t know of a fix for this, I’m guessing br, hr etc. are hard coded somewhere in ST core, so only HTML tags are supported like this…

AFAIK the close_tag command only accepts one argument called insert_slash. Probably the best workaround is to write your own close_tag command to work with your XPX syntax, and override the default keybinding for / to use that in an XPX context.

2 Likes

#3

Effectively, i realised shortly that if i write my XPX inline tag with the / of the end, sublime text close tag runs ok.
Example : div> img> set /> /div>

In my tests, i try :

  • to define scope as for img in tex.html : no success
  • to use the end / for inline tags : success but we would like to stay in HTML 5 format.
  • to define my own xpx_close_tag : no success because i can’t override the / keybinding.

So maybe wbond would help me ? or FichteFoll ?

It is the last step to post my v1.0.0 and use definitly the sublime text in place of dreamweaver that licence stop at the 31 of august.

Thanks for your help.

0 Likes

#4

I got to create a new command called xpx_close_tag.
And now I’m trying to manipulate the stack of tags to inhibit the closing of XPX inline tags.
I keep you informed.

0 Likes

#5

Hello everybody,

I just finished rewriting the sublime (core) close_tag function to take into account the xpx tags for closing regardless of XPX inline tags.

At first, I thought that html scopes were used to distinguish block tags from inline tags in html.sublime-syntax, but it happens that the inline scope is also distributed on block tags in html (I do not know why) (for example : table, tr, td, …). So, I rewrote a LIFO stack management in order to cause the correct closing of HTML and XPX tags.

You can see the result in xpx_close_tag.py in the github project (Package control for sublime/XPX).

0 Likes