Fix blockquotes
* nesting did not work * ">" without following space was not recognized as blockquote Quoting https://spec.commonmark.org/0.29/#example-5: > Normally the > that begins a block quote may be followed optionally by a space, which is not considered part of the content.
This commit is contained in:
parent
028a8dadd1
commit
23241209f8
1 changed files with 16 additions and 6 deletions
22
smu.c
22
smu.c
|
@ -44,7 +44,7 @@ static int nohtml = 0;
|
||||||
static Tag lineprefix[] = {
|
static Tag lineprefix[] = {
|
||||||
{ " ", 0, "<pre><code>", "\n</code></pre>" },
|
{ " ", 0, "<pre><code>", "\n</code></pre>" },
|
||||||
{ "\t", 0, "<pre><code>", "\n</code></pre>" },
|
{ "\t", 0, "<pre><code>", "\n</code></pre>" },
|
||||||
{ "> ", 2, "<blockquote>", "</blockquote>" },
|
{ ">", 2, "<blockquote>", "</blockquote>" },
|
||||||
{ "###### ", 1, "<h6>", "</h6>" },
|
{ "###### ", 1, "<h6>", "</h6>" },
|
||||||
{ "##### ", 1, "<h5>", "</h5>" },
|
{ "##### ", 1, "<h5>", "</h5>" },
|
||||||
{ "#### ", 1, "<h4>", "</h4>" },
|
{ "#### ", 1, "<h4>", "</h4>" },
|
||||||
|
@ -212,12 +212,22 @@ dolineprefix(const char *begin, const char *end, int newblock) {
|
||||||
if(!(buffer = malloc(BUFSIZ)))
|
if(!(buffer = malloc(BUFSIZ)))
|
||||||
eprint("Malloc failed.");
|
eprint("Malloc failed.");
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
for(j = 0, p += l; p < end; p++, j++) {
|
|
||||||
ADDC(buffer, j) = *p;
|
/* Collect lines into buffer while they start with the prefix */
|
||||||
if(*p == '\n' && p + l < end) {
|
j = 0;
|
||||||
if(strncmp(lineprefix[i].search, p + 1, l) != 0)
|
while((strncmp(lineprefix[i].search, p, l) == 0) && p + l < end) {
|
||||||
break;
|
|
||||||
p += l;
|
p += l;
|
||||||
|
|
||||||
|
/* Special case for blockquotes: optional space after > */
|
||||||
|
if(lineprefix[i].search[0] == '>' && *p == ' ') {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(p < end) {
|
||||||
|
ADDC(buffer, j) = *p;
|
||||||
|
j++;
|
||||||
|
if(*(p++) == '\n')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue