remarkjs / remark-directive

remark plugin to support directives
https://remark.js.org
MIT License
250 stars 15 forks source link

Parsing of inline directive collides with usage of colon in natural language. (E.g. `n:th`) #5

Closed ViktorQvarfordt closed 3 years ago

ViktorQvarfordt commented 3 years ago

Subject of the issue

Parsing of inline directive collides with usage of colon in natural language. (E.g. n:th)

Your environment

codesandbox

Steps to reproduce

https://codesandbox.io/s/remark-rehype-debug-forked-oetjj?file=/src/index.js

Expected behavior

Expecting directive to not be parsed if the colon (:) is preceded by a letter or number.

Actual behavior

Input:

The n:th element.

Output:

<p>The n</p><div></div> element.<p></p>
wooorm commented 3 years ago

Why shouldn’t it? If you don’t want colons turning into a directive, add an escape before: n\:th. the current behavior allows footnotes and the like: some text:fn[1].

Also: why write it like n:th? Why not nth, n’th, or n-th? https://en.wiktionary.org/wiki/nth

ViktorQvarfordt commented 3 years ago

Good point. Thanks for elaborating. The current behavior makes sense.