ext/xhtml.c in redcarpet-1.7.1 vs ext/xhtml.c in redcarpet-1.8.0

- old
+ new

@@ -110,17 +110,17 @@ return 1; } static void -rndr_blockcode(struct buf *ob, struct buf *text, struct buf *syntax, void *opaque) +rndr_blockcode(struct buf *ob, struct buf *text, struct buf *lang, void *opaque) { if (ob->size) bufputc(ob, '\n'); - if (syntax && syntax->size) { + if (lang && lang->size) { BUFPUTSL(ob, "<pre lang=\""); - bufput(ob, syntax->data, syntax->size); + bufput(ob, lang->data, lang->size); BUFPUTSL(ob, "\"><code>"); } else BUFPUTSL(ob, "<pre><code>"); if (text) @@ -232,24 +232,44 @@ } static void rndr_paragraph(struct buf *ob, struct buf *text, void *opaque) { + struct xhtml_renderopt *options = opaque; size_t i = 0; if (ob->size) bufputc(ob, '\n'); if (!text || !text->size) return; while (i < text->size && isspace(text->data[i])) i++; - if (i < text->size) { - BUFPUTSL(ob, "<p>"); + if (i == text->size) + return; + + BUFPUTSL(ob, "<p>"); + if (options->flags & XHTML_HARD_WRAP) { + size_t org; + while (i < text->size) { + org = i; + while (i < text->size && text->data[i] != '\n') + i++; + + if (i > org) + bufput(ob, text->data + org, i - org); + + if (i >= text->size) + break; + + BUFPUTSL(ob, "<br/>"); + i++; + } + } else { bufput(ob, &text->data[i], text->size - i); - BUFPUTSL(ob, "</p>\n"); } + BUFPUTSL(ob, "</p>\n"); } static void rndr_raw_block(struct buf *ob, struct buf *text, void *opaque) { @@ -646,17 +666,17 @@ NULL, NULL, NULL, NULL, - rndr_autolink, + NULL, rndr_codespan, rndr_double_emphasis, rndr_emphasis, - rndr_image, - rndr_linebreak, - rndr_link, - rndr_raw_html, + NULL, + NULL, + NULL, + NULL, rndr_triple_emphasis, NULL, NULL,