Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add MKDEXT_LAX_SPACING extension

  • Loading branch information...
commit 38261808f93a1f81ba0be0627370c58441c4357b 1 parent 0e1cb2b
@vmg vmg authored
Showing with 31 additions and 16 deletions.
  1. +30 −15 src/markdown.c
  2. +1 −1  src/markdown.h
View
45 src/markdown.c
@@ -1426,18 +1426,38 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
if ((level = is_headerline(data + i, size - i)) != 0)
break;
- if (rndr->ext_flags & MKDEXT_LAX_HTML_BLOCKS) {
- if (data[i] == '<' && rndr->cb.blockhtml && parse_htmlblock(ob, rndr, data + i, size - i, 0)) {
+ /*
+ * Early termination of a paragraph with the same logic
+ * as Markdown 1.0.0. If this logic is applied, the
+ * Markdown 1.0.3 test suite won't pass cleanly
+ *
+ * :: If the first character in a new line is not a letter,
+ * let's check to see if there's some kind of block starting
+ * here
+ */
+ if ((rndr->ext_flags & MKDEXT_LAX_SPACING) && !isalnum(data[i])) {
+ if (is_atxheader(rndr, data + i, size - i) ||
+ is_hrule(data + i, size - i) ||
+ prefix_quote(data + i, size - i) ||
+ prefix_oli(data + i, size - i) ||
+ prefix_uli(data + i, size - i)) {
end = i;
break;
}
- }
- if (is_atxheader(rndr, data + i, size - i) ||
- is_hrule(data + i, size - i) ||
- prefix_quote(data + i, size - i)) {
- end = i;
- break;
+ /* see if an html block starts here */
+ if (data[i] == '<' && rndr->cb.blockhtml &&
+ parse_htmlblock(ob, rndr, data + i, size - i, 0)) {
+ end = i;
+ break;
+ }
+
+ /* see if a code fence starts here */
+ if ((rndr->ext_flags & MKDEXT_FENCED_CODE) != 0 &&
+ is_codefence(data + i, size - i, NULL) != 0) {
+ end = i;
+ break;
+ }
}
i = end;
@@ -1802,13 +1822,8 @@ htmlblock_end_tag(
i += w;
w = 0;
- if (rndr->ext_flags & MKDEXT_LAX_HTML_BLOCKS) {
- if (i < size)
- w = is_empty(data + i, size - i);
- } else {
- if (i < size && (w = is_empty(data + i, size - i)) == 0)
- return 0; /* non-blank line after tag line */
- }
+ if (i < size)
+ w = is_empty(data + i, size - i);
return i + w;
}
View
2  src/markdown.h
@@ -56,9 +56,9 @@ enum mkd_extensions {
MKDEXT_FENCED_CODE = (1 << 2),
MKDEXT_AUTOLINK = (1 << 3),
MKDEXT_STRIKETHROUGH = (1 << 4),
- MKDEXT_LAX_HTML_BLOCKS = (1 << 5),
MKDEXT_SPACE_HEADERS = (1 << 6),
MKDEXT_SUPERSCRIPT = (1 << 7),
+ MKDEXT_LAX_SPACING = (1 << 7),
};
/* sd_callbacks - functions for rendering parsed data */
Please sign in to comment.
Something went wrong with that request. Please try again.