Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

How should tag coloring be done #9

Open
lassik opened this issue Feb 9, 2018 · 2 comments
Open

How should tag coloring be done #9

lassik opened this issue Feb 9, 2018 · 2 comments

Comments

@lassik
Copy link

lassik commented Feb 9, 2018

Currently bbcode-mode only colors matching pairs of opening/closing tags. It doesn't color orphaned opening or closing tags at all (i.e. an opening tag without a matching closing tag or vice versa). This can be quite confusing to newcomers since the behavior is different from popular Emacs modes like xml-mode, html-mode and web-mode, all of which color orphaned tags as well as properly paired ones. (xml-mode goes a step further and colors orphaned closing tags in red to highlight that there's a syntax error, but that's tricky to do.)

As a related issue, bbcode-mode tries to implement tag pair matching using a regexp. This does not work properly with nested tags - in particular, nested [quote]s are problematic. It's very difficult if not impossible to properly parse nested structures using regexps.

In light of these points, I'd like to propose that the font-lock patterns should simply match individual opening/closing tags and not worry about pairing them up. This would make bbcode-modes font-lock behavior consistent with existing popular markup modes and would make the font-lock patterns much simpler to implement as well. What do you think?

@lassik
Copy link
Author

lassik commented Feb 9, 2018

#7 seems related

@lassik
Copy link
Author

lassik commented Feb 9, 2018

I see that when typing [b]foo[/b] the whole text is bolded which is nice. web-mode doesn't do that. html-mode seems like the best of both worlds: orphaned tags are colored and the foo part in <b>foo</b> is also bolded :) But it's not too ambitious: the foo part in <b><a href="x">foo</a></b> is not bolded. Maybe we could try going for this level of sophistication.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant