ext/markdown.c in rtomayko-rdiscount-1.3.1.2 vs ext/markdown.c in rtomayko-rdiscount-1.3.4
- old
+ new
@@ -122,10 +122,18 @@
p = p->next;
return p;
}
+void
+___mkd_tidy(Line *t)
+{
+ while ( S(t->text) && isspace(T(t->text)[S(t->text)-1]) )
+ --S(t->text);
+}
+
+
static char *
isopentag(Line *p)
{
int i=0, len;
struct kw key, *ret;
@@ -432,16 +440,10 @@
static Line *
codeblock(Paragraph *p)
{
Line *t = p->text, *r;
- /* HORRIBLE STANDARDS KLUDGE: the first line of every block
- * has trailing whitespace trimmed off.
- */
- while ( S(t->text) && isspace(T(t->text)[S(t->text)-1]) )
- --S(t->text);
-
for ( ; t; t = r ) {
CLIP(t->text,0,4);
t->dle = mkd_firstnonblank(t);
if ( !( (r = skipempty(t->next)) && iscode(r)) ) {
@@ -490,16 +492,17 @@
static Line *
textblock(Paragraph *p, int toplevel)
{
Line *t, *next;
- for ( t = p->text; t ; t = next )
+ for ( t = p->text; t ; t = next ) {
if ( ((next = t->next) == 0) || endoftextblock(next, toplevel) ) {
p->align = centered(p->text, t);
t->next = 0;
return next;
}
+ }
return t;
}
/* length of the id: or class: kind in a special div-not-quote block
@@ -831,9 +834,17 @@
else
ptr = htmlblock(p, key);
}
else if ( iscode(ptr) ) {
p = Pp(&d, ptr, CODE);
+
+ if ( f->flags & MKD_1_COMPAT) {
+ /* HORRIBLE STANDARDS KLUDGE: the first line of every block
+ * has trailing whitespace trimmed off.
+ */
+ ___mkd_tidy(p->text);
+ }
+
ptr = codeblock(p);
}
else if ( ishr(ptr) ) {
p = Pp(&d, 0, HR);
r = ptr;