tsunami
log in
email
password
links
newest items
tag list
syntax reference
tag:time
history
points to
tsunami syntax
add
item name
tags
==Introduction Time allows \_italics_ and \*bolding\*: _italics_ and *bolding*. The trick is this: which underscores and which asterisks trigger markup? This is not the easiest of questions. =Was this {{ html = Regex.Replace(html, @" (?<= # the character before the _ must be: ^ # beginning of the string | # or [ \t>(\r\n] # space, tab, open paren, end of line ) _ # the underscore that gets removed ( (?: # one or more of: [^_<>] # no underscores or other HTML markup (from previous replaces) | # or \\\\_ # escaped underscores are allowed )+? ) (?<!\\\\) # don't match an underscore if it is escaped _ # the ending underscore that gets removed ", "<em>$1</em>", RegexOptions.IgnorePatternWhitespace); }} =Currently {{ var map = new Dictionary<string, string>(); map["_"] = "em"; map["*"] = "strong"; map["--"] = "strike"; // emphasize, bold, strikethrough html = Regex.Replace(html, @" (?<!\\\\) (?<=[ \\t>(\\r\\n\\-]|^) #yuck... had to remove [a-z], as a_b_c should NOT italicize b (_|\\*|--) (?![ \\t\\r\\n`]) ( (?: (?!\\1)[^<>\\r\\n] | \\\\\\1 )+? ) (?<!\\\\) \\1", m => string.Format("<{0}>{1}</{0}>", map[m.Groups[1].Value], m.Groups[2]), RegexOptions.IgnorePatternWhitespace); }} =Problem {{ \\_italics_ and \\*bolding*: _italics_ and *bolding* bold: ^^^^^^^^^^^^^^^^ italic: }} (I'm not sure I want to have to escape all * and _ and --.)
some permissive license goes here
contact