-
-
Notifications
You must be signed in to change notification settings - Fork 19
Apply directives only on tags starting with a letter #28
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Problem
Our users are reporting problems with writing time values. E.g. the value "12:30pm" is transformed to 12<30pm /> after parsing it with this plugin and converting it to HTML. This will result in displaying just "12" when we will pass this through sanitization that discards unknown tags. Without the sanitization it will throw the error Invalid tag: 30pm and fail to render the text.
I know, that the current recommendation to handle this is to add the escape character like this: "12:30pm", but our users will usualy forget about this or they even don't know about it and they are confused by the missing text.
Moreover, the HTML specification actually forbids the tag names to start with anything else than a letter. So, it seems to me, that trying to interpret such syntax as tag names, doesn't make sense.
document.createElement('30pm');
VM2075:1 Uncaught InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('30pm') is not a valid name.
Current solutions
To fix this I would have to create a new remark plugin, that would be ran after remark-directive, that would go through all directives, check their tag names and revert those not starting with a letter back to the plain text.
Proposed solutions
Alter the directives parsing algorhitm to only create directives, if the directive name is starting with a letter.