micromark / micromark-extension-directive

micromark extension to support generic directives (`:cite[smith04]`)
https://unifiedjs.com
MIT License
31 stars 16 forks source link

Adds support for colons in directive names #19

Open maximilliangeorge opened 1 year ago

maximilliangeorge commented 1 year ago

Initial checklist

Description of changes

This PR adds support for colons within a leaf directory name. This syntax is helpful to create namespaced methods, like so: ::hello:alice and ::hello:bob.

I needed this for a particular use case and wasn't planning on submitting a PR to the original repo. In honesty, it probably shouldn't be merged since it isn't according to the common spec. Still, I'm submitting it here for transparency and interesting conversations.

wooorm commented 1 year ago

I like this because JSX/XML/HTML also support a “namespace” (:svg:rect). I dislike this because it is close to conflicting with gemoji shortcodes (see also this related fix) in the text variant (:wave:how are you?). It’s probably not common to use a word directly after a gemoji, but gemoji are very common, so I’d imagine it exists in the wild.

If a colon was supported, I think we shouldn’t allow them arbitrarily: :a::::::::::::::::b seems weird. Instead, I think I’d like them to work as “two” names, with a single colon in between, and that dashes or underscores cannot be used to end each name part (so :a-:b would not be ok).