Hi,
I added code to the Wysiwyg editor to escape markup within text nodes. To illustrate here is an example from the (javascript) test-suite:
it("should escaped text containing link markup", function() {
expect("To create a link, put it between <code>*</code>").shouldParseInto("To create a link, put it between ==\\*==");
});
This works fine, the problem arises with:
it("should escaped text containing code markup", function() {
expect("To make something <code>monospaced</code>, surround it with <code>==</code>").shouldParseInto("To make something ==monospaced==, surround it with ==\\=\\===");
});
Should text containing '==' translate into '\==' OR '\=\='.
rendering ' ==\==== ' into html [1] results in:
'<p> <code>=</code>= </p>'
whereas rendering '==\=\=== ' into html results in:
'<p> <code>==</code> </p>'
The html reflects the PRDocument structure. It seems that PRDocumentParser doesn't parse ' ==\==== ' as expected.
Worse the sequence: wiki text-> PRDocument -> wiki text fails:
PRWikiWriter write: (PRDocumentParser parse: ' ==\=\=== ') => ' ==\==== '
However I have a fix. I've locally modified PRDocumentParser class>>#escape:using: so that any multi-character markup is multiply escaped:
'@@' -> '\@\@'
'--' => '\-\-'
This seems to solve the ambiguous parsing problem and the round-trip problem. Great. However many tests will need rewriting to reflect that any multi-character markup is escaped with multiple slashes. Before fixing the tests, I wanted to check that people thought it made sense.
Thanks
Nick
[1] | document renderer |
document := PRDocumentParser parse: ' ==\==== '.
renderer := PRViewRenderer new.
^ WAHtmlCanvas builder
fullDocument: false;
render: [ :r | renderer withinContentDo: [ renderer start: document in: self on: r ] ].