FR: replace --> with →
Hi, what do you think about maybe adding the following replacement to your replacements extension:
Replace --> with →
That would be very useful to write documentations where I often want to say something like: Go to this menu: Files -> Sessings -> Colors
I would try and provide an PR if you agree.
Thanks Philip
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Thanks @PhilipMay, it definitely seems feasible as we are already looking for --; in markdown_it/rules_core/replacements.py adding something like ARROW_RE = re.compile(r"(^|\s)-->(?=\s|$)", flags=re.MULTILINE)
This being a port though, this issue perhaps makes it a bit problematic to implement directly in "core" 😬: https://github.com/markdown-it/markdown-it/issues/543 Meaning it might be best to essentially extract the replacement code into a plugin in https://github.com/executablebooks/mdit-py-plugins, where we can be a bit more flexible
@chrisjsewell so you mean that I should add it as a plugin at https://github.com/executablebooks/mdit-py-plugins right?
Could you please give me some more hints on how to do that? Is there any documentation? Is there a plugin I could use as a template or is there already a plugin I could extend?
so you mean that I should add it as a plugin at executablebooks/mdit-py-plugins right?
yep 👍
Is there any documentation?
There not actually any documentation specifically for creating plugins (yet), but obviously if you haven't already read https://markdown-it-py.readthedocs.io/en/latest/using.html and https://markdown-it-py.readthedocs.io/en/latest/architecture.html
The plugin would look something like this, such that you literally are replacing the current "replace" rule (in https://github.com/executablebooks/markdown-it-py/blob/master/markdown_it/rules_core/replacements.py) with a different one:
def replace_plus_plugin(md: MarkdownIt):
# Replace existing replace rule by name with new function.
md.core.ruler.at("replace", replace_plus)
def replace_plus(state: StateCore, *args, **kwargs) -> None:
for token in state.tokens:
if token.type != "inline":
continue
assert token.children is not None
if SCOPED_ABBR_RE.search(token.content):
replace_scoped(token.children)
if RARE_RE.search(token.content):
replace_rare(token.children)
Although I just realised this won't actually work yet in v0.6.2 , because of #146 😬
Great @chrisjsewell I will check this...
Well - #146 seems to be merged new. I do not think that I will provide a PR. @chrisjsewell maybe you could provide one?