I have a javascript string that I need to split by format type written inside the string so that I can output bold and italic text in jade such that
"Hello {b World b}{i and everyone i} else! And {i hello to you i}. 1 < 5."
would output:
Hello World and everyone else! And hello to you. 1 < 5
The string contains an indeterminate amount of these tags (0+) in any order, but I only care about "i" and "b" tags. I've tried a simple string.replace and tried injecting html:
- line = line.replace("{b ", "<b>");
- line = line.replace(" b}", "</b>");
- line = line.replace("{i ", "<i>");
- line = line.replace(" i}", "</i>");
| #{line}
But the jade template tries to be smart and outputs:
"Hello <b>World</b><i>and everyone</i> else! And <i>hello to you</i>. 1 < 5"
because it converts each to
< and >
Note that the string may contain < or > inside. I'm totally stuck.