Hi all,
I'm trying to trim out some edge-cases in my txt2tags parser. There
are some fairly strict formatting rules:
This is a **bold** word. White space matters, so ** this** isn't bold.
Nor is **this **.
**spaces are ok in between words, but not adjacent to the markup characters**.
If you don't match your markup (on the same newline) ** then you get
just that floating pair of astrices.
If you stack up the markup: ***this*** would appear as <strong>*this*</strong>.
First I was using this:
{
name: 't2tBold',
match: '\\*\\*',
termRegExp: /(\*\*|\n)/mg,
element: 'strong',
handler: config.formatterHelpers.createElementAndWikify
}
This has the following bad behavior:
If I do ** this, then the whole line is made bold because there is no
termination.
Also, ***this*** becomes <strong>*this</strong>*
Finally, the whitespace rules are ignored.
I changed it to this
{
name: 't2tBold',
match: '\\*\\*',
(honestly don't fully undestand the difference between ?:. and |.
used below... I'm in cut-and-paste territory as far as my regex skills
go)
//lookaheadRegExp: /\*\*([^\s](?:.)*?[^\s]\**)(\*\*)/mg,
lookaheadRegExp: /\*\*([^\s](|.*?[^\s])\**)\*\*/mg,
element: 'strong',
handler: config.formatterHelpers.enclosedTextHelper
},
This works in the ***bold*** example; and it obeys the whitespace
rule. BUT the problem I'm getting is with mismatched markup:
This ** won't work. --> This won't work.
The markup is consumed by enclosedTextHelper because it is the "match:" portion.
Is there one of the formatterHelper functions that doesn't consume the
first "match"?
--
David Young
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywikidev?hl=en.