Closed NQNStudios closed 6 years ago
Can you comment back with an example of how this would work?
Alongside a regular alias definition, a regex definition looks like this:
"aliases": [
{ "regex": "vibe:(?<tag>[A-Za-z]+)", "replaceWith": "<span class='conditional' data-vibe-tag='${tag}'>", "end": "</span>" },
{ "alias": "backButton", "replaceWith": "<a href='javascript:Core.GotoPreviousSection();'><i class=\"fa fa-arrow-left\" aria-hidden=\"true\"></i> Back</a>" }
]
A regex alias looks exactly like a regular one when it's invoked, depending on how complicated the regex is. In the given example, anything in the pattern {vibe:[SomeWord]}
will be converted into the replaceWith
pattern that can invoke [SomeWord] wherever it needs to.
What this means for me is, if I need to define a lot of divs in the body of my sections, and each with their own id, I could declare an alias like this:
{ "regex": "div:(?<id>[A-Za-z]+)", "replaceWith": "<div id='${id}'>"
and suddenly I have a very convenient way to define an identifiable div in Markdown.
What? Six weeks is a totally normal amount of time for reviewing and accepting a PR... right? >_>
I wanted to be able to define a single alias that would handle a range of expressions (essentially, giving aliases internal parameters that could be included in the replacement). So I made that a thing.
Changes proposed by this pull request:
@invicticide to review