Img tags implicit closing only occurs at EOF/end of post, ignoring all nesting.

Joined
Apr 23, 2018
Messages
1,071
Wrote this to help me diagnose the issue. While it would be sort of nice to have it fixed (tbh, even I don't expect this feature, though I do utilize implicit closing for other tags), this was mostly just to help me understand the process so I could reproduce it in my post preview userscript (link near the bottom of my MD profile).
This should be low priority, next to the spikes at the bottom of the cliff that the M devs are pushed off of when nothing else will stimulate them, as I am probably the only person who actually uses implicit tag closing (what type of weirdos even know about this feature anyways?).

Img (and url) tags are implicitly closed on EOF regardless of their validity or of any nesting they had. I expect
1) Them to be closed with their parent like other tags (when nested)
2) Them to be invalidated (not considered to be bbcode, but normal text) when they do not conform to the html generator's specifications (eg. html generator rejects empty tags, but whatever is implicitly closing img tags doesn't)

Seems like processing of bbcode occurs in multiple stages. Whatever step does implicit closing of img/url tags probably just needs a regex that matches the html generation stage better.
Also curious why only img/url fails with implicit closing, is it handled separately from some bbcode package, or is it a small typo in a custom grammar?

While looking at actual code would be ideal, my outside analysis leads me to believe the html generator step looks for urls in a format similar to:
Code:
\[img\][a-zA-Z0-9\-]+://\S*\.\S*(<CLOSING_TAG_FOR_THIS_OR_ANY_PARENT_CONTEXT>|\s*$)
$ being EOF, not EOL

Making the following valid
EOF (with or without trailing whitespace):
Code:
[[s][/s]img]-://.
Nested close:
Code:
[ul[s][/s]][[s][/s]img]-://.[[s][/s]/ul]
And the following invalid:
Space:
Code:
[ul[s][/s]][[s][/s]img]-://. [[s][/s]/ul]
Newline:
Code:
[[s][/s]img]-://.
a
Empty:
Code:
[[s][/s]img]

Alternatively, white space itself could implicitly close it. Though the regex(I am assuming) change is still kind of needed...
Also, while Implicit closing of tags makes sense, it is kind of odd that it is done in a textual manner, rather than in an ast. Though I guess that really depends on what your using to parse and generate it.

Example:
Nested with space invalidation (this is what I actualy typed below):
Code:
[ul[s][/s]][img[s][/s]]https://mangadex.org/images/avatars/36341.png [/ul[s][/s]]
[ul]
ul]
 
Instrumentality Instigator
Staff
Super Moderator
Joined
Jan 29, 2018
Messages
1,343
I appreciate all the work you've been doing to help with minor things. They've saved devs some trouble! I'll drop this thread where they can see it.
 

Users who are viewing this thread

Top