Folks, If you look at the core tiddler $:/core/modules/parsers/wikiparser/rules/horizrule.js
(on a copy of empty.html to be safe)
You will see it has a regular expression to detect three hyphens, presumably at the begining of a line, or on its own line this.matchRegExp = /-{3,}\r?(?:\n|$)/mg;
Then if matched replaces this with <hr>
My Regular expression skills are week at best, so I hope someone can tell me the regular expression to match ↩︎ anywhere in the text
Then I will clone this tiddler change this to replace ↩︎ with <br> during the parsing.
I will make an editor toolbar in support of this, and share back
The idea is to find a single character ↩︎ replacement for the use of <br> in wikitext which looks ugly in text otherwise devoid of html tags.
Your assistance would be greatly appreciated.
Post script;
The same regexp can possibly used for many different single character to html tag parser one could think of.
Although different parser code may be needed to wrap text etc… ie identify the end of line, which I think this.matchRegExp = /-{3,}\r?(?:\n|$)/mg; is doing.
I think the answer might be right there in your original regexp. The \r looks for a line return and the \n looks for a linefeed (shame that we’re still bound to 20th century carriage printer technologies). The search is looking for the first line feed followed by a line return OR the end of the text.
/↩︎\r?(?:\n|$)/gm
↩︎ matches the characters ↩︎ literally (case sensitive)
\r matches a carriage return (ASCII 13)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
Non-capturing group (?:\n|$)
1st Alternative \n
\n matches a line-feed (newline) character (ASCII 10)
2nd Alternative $
$ asserts position at the end of a line
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)