Talk:Parsoid/Debugging
Latest comment: 10 years ago by Nbrouard in topic Debugging the wt2html mode
Debugging the wt2html mode
editOn Linux I have to do:
$ echo "foo bar
> This is a [[link]]" | node parse --trace peg
0-[peg] | ----> ["foo bar"]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[7,8]}}]
0-[peg] | ----> ["This is a ",{"type":"SelfclosingTagTk","name":"wikilink","attribs":[{"k":"href","v":["link"],"vsrc":"link"}],"dataAttribs":{"tsr":[18,26],"src":"[[link]]"}}]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[26,27]}}]
0-[peg] | ----> [{"type":"EOFTk"}]
in order to get the correct output, otherwise, I get:
$ echo "foo bar\nThis is a [[link]]" | node parse --trace peg
0-[peg] | ----> ["foo bar\\nThis is a ",{"type":"SelfclosingTagTk","name":"wikilink","attribs":[{"k":"href","v":["link"],"vsrc":"link"}],"dataAttribs":{"tsr":[19,27],"src":"[[link]]"}}]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[27,28]}}]
0-[peg] | ----> [{"type":"EOFTk"}]
Probably adding the '-e' option would be perfect:
$ echo -e "foo bar\nThis is a [[link]]" | node parse --trace peg
0-[peg] | ----> ["foo bar"]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[7,8]}}]
0-[peg] | ----> ["This is a ",{"type":"SelfclosingTagTk","name":"wikilink","attribs":[{"k":"href","v":["link"],"vsrc":"link"}],"dataAttribs":{"tsr":[18,26],"src":"[[link]]"}}]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[26,27]}}]
0-[peg] | ----> [{"type":"EOFTk"}]
Looking around, it seems that the POSIX echo doesn't accept the '-e' argument. In fact, the standard bash shell doesn't seem to be standard according to the POSIX echo. We have to use tcsh to run your tests.
$ tcsh
$ echo "foo bar\nThis is a [[link]]" | node parse --trace peg
0-[peg] | ----> ["foo bar"]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[7,8]}}]
0-[peg] | ----> ["This is a ",{"type":"SelfclosingTagTk","name":"wikilink","attribs":[{"k":"href","v":["link"],"vsrc":"link"}],"dataAttribs":{"tsr":[18,26],"src":"[[link]]"}}]
0-[peg] | ----> [{"type":"NlTk","dataAttribs":{"tsr":[26,27]}}]
0-[peg] | ----> [{"type":"EOFTk"}]