mirror of
https://github.com/Orc/discount.git
synced 2026-09-25 04:10:00 +03:00
1. If a full tick match isn't found, choose the closest
substring match. 2. Move code test cases to code.t 3. Add new code test cases to check that the code handler works like the standard does.
This commit is contained in:
+16
-6
@@ -21,7 +21,7 @@ typedef int (*stfu)(const void*,const void*);
|
||||
|
||||
|
||||
/* forward declarations */
|
||||
static int matchticks(MMIOT*, int);
|
||||
static int matchticks(MMIOT*, int*);
|
||||
static void codeblock(MMIOT*);
|
||||
static void codespan(MMIOT*, int);
|
||||
static int nrticks(int, MMIOT*);
|
||||
@@ -1071,7 +1071,7 @@ text(MMIOT *f)
|
||||
else {
|
||||
int size, tick = nrticks(0, f);
|
||||
|
||||
if ( size = matchticks(f, tick) ) {
|
||||
if ( size = matchticks(f, &tick) ) {
|
||||
shift(f, tick);
|
||||
codespan(f, size-tick);
|
||||
shift(f, size-1);
|
||||
@@ -1126,19 +1126,29 @@ text(MMIOT *f)
|
||||
|
||||
|
||||
static int
|
||||
matchticks(MMIOT *f, int escape)
|
||||
matchticks(MMIOT *f, int *escape)
|
||||
{
|
||||
int size, tick, c;
|
||||
int subsize=0, subtick=0;
|
||||
|
||||
for (size = escape; (c=peek(f,size)) != EOF; ) {
|
||||
for (size = *escape; (c=peek(f,size)) != EOF; ) {
|
||||
if ( c == '`' )
|
||||
if ( (tick=nrticks(size,f)) == escape )
|
||||
if ( (tick=nrticks(size,f)) == *escape )
|
||||
return size;
|
||||
else
|
||||
else {
|
||||
if ( !subsize ) {
|
||||
subsize = size;
|
||||
subtick = tick;
|
||||
}
|
||||
size += tick;
|
||||
}
|
||||
else
|
||||
size++;
|
||||
}
|
||||
if ( subsize ) {
|
||||
*escape = subtick;
|
||||
return subsize;
|
||||
}
|
||||
return 0;
|
||||
|
||||
} /* matchticks */
|
||||
|
||||
@@ -15,6 +15,11 @@ code
|
||||
try 'unclosed single backtick' '`hi there' '<p>`hi there</p>'
|
||||
try 'unclosed double backtick' '``hi there' '<p>``hi there</p>'
|
||||
try 'remove space around code' '`` hi there ``' '<p><code>hi there</code></p>'
|
||||
try '`` a```b ``' '`` a```b ``' '<p><code>a```b</code></p>'
|
||||
try '`a\`' '`a\`' '<p><code>a\</code></p>'
|
||||
try '`>`' '`>`' '<p><code>></code></p>'
|
||||
try '`` ` ``' '`` ` ``' '<p><code>`</code></p>'
|
||||
try '````` ``` `' '````` ``` `' '<p><code>``</code> `</p>'
|
||||
|
||||
summary $0
|
||||
exit $rc
|
||||
|
||||
@@ -7,10 +7,6 @@ MARKDOWN_FLAGS=
|
||||
|
||||
try 'single paragraph' 'AAA' '<p>AAA</p>'
|
||||
try '< -> <' '<' '<p><</p>'
|
||||
try '`>` -> <code>></code>' '`>`' '<p><code>></code></p>'
|
||||
try '`` ` `` -> <code>`</code>' '`` ` ``' '<p><code>`</code></p>'
|
||||
try '`` a```b ``' '`` a```b ``' '<p><code>a```b</code></p>'
|
||||
try '`a^A` -> <code>a^A</code>' '`a^A`' '<p><code>a^A</code></p>'
|
||||
|
||||
summary $0
|
||||
exit $rc
|
||||
|
||||
Reference in New Issue
Block a user