ref: b62b78aac71e6db9a50a25c68b0f2fb3fa267cc2
parent: 6dc9af5780482f804e09adc3cf8b9b8b39527ac6
author: stanley lieber <stanley.lieber@gmail.com>
date: Fri Mar 7 06:44:05 EST 2014
mothra: handle blank lines inside <pre> tags
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -540,9 +540,9 @@
return ENDTAG;
}
/*
- * The next token is a tag, an end tag or a sequence of
- * non-white characters.
- * If inside <pre>, newlines are converted to <br> and spaces are preserved.
+ * The next token is a tag, an end tag or a sequence of non-white
+ * characters. If inside <pre>, single newlines are converted to <br>,
+ * double newlines are converted to <p> and spaces are preserved.
* Otherwise, spaces and newlines are noted and discarded.
*/
int pl_gettoken(Hglob *g){@@ -552,8 +552,15 @@
case STAG: return pl_gettag(g);
case EOF: return EOF;
case '\n':
- pl_tagparse(g, "br");
- return TAG;
+ switch(c=pl_nextc(g)){+ case '\n':
+ pl_tagparse(g, "p");
+ return TAG;
+ default:
+ pl_tagparse(g, "br");
+ pl_putback(g, c);
+ return TAG;
+ }
default:
tokp=g->token;
while(c=='\t'){--
⑨