Skip to content

Apply directives only on tags starting with a letter #28

@radarfox

Description

@radarfox

Initial checklist

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙋 no/questionThis does not need any changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions