From 376656c77c61fe3f5f1caac2b2d0161d98cf0676 Mon Sep 17 00:00:00 2001 From: david parsons Date: Sun, 2 Oct 2022 02:46:26 -0700 Subject: [PATCH] the behavior of tags-starting-with-alpha-/-! was not like that of the reference implementation; fixed (in a very script-kiddy leaky fashion which I can't resolve with a runtime flag thanks to the 32 bit flags field in the 2.x series :-( --- generate.c | 47 +++++++++++++++++----------------------------- tests/automatic.t | 8 ++++---- tests/githubtags.t | 6 +++--- tests/muñoz.t | 4 ++-- 4 files changed, 26 insertions(+), 39 deletions(-) diff --git a/generate.c b/generate.c index 29309af..2f58d60 100644 --- a/generate.c +++ b/generate.c @@ -1046,49 +1046,36 @@ process_possible_link(MMIOT *f, int size) static int maybe_tag_or_link(MMIOT *f) { - int c, size; - int maybetag = 1; + int c, size=0; if ( is_flag_set(&f->flags, MKD_TAGTEXT) ) return 0; - for ( size=0; (c = peek(f, size+1)) != '>'; size++) { - if ( c == EOF ) - return 0; - else if ( c == '\\' ) { - maybetag=0; - if ( peek(f, size+2) != EOF ) - size++; - } - else if ( isspace(c) ) - break; - else if ( ! (c == '/' - || (is_flag_set(&f->flags, MKD_GITHUBTAGS) && (c == '-' || c == '_')) - || isalnum(c) ) ) - maybetag=0; - } + c = peek(f, 1); - if ( size ) { - if ( maybetag || (size >= 3 && strncmp(cursor(f), "!--", 3) == 0) ) { - - /* It is not a html tag unless we find the closing '>' in - * the same block. - */ - while ( (c = peek(f, size+1)) != '>' ) + if ( isalpha(c) || c == '/' || c == '!' ) { + /* By decree of Markdown.pl *this is a tag* */ + while ( (c=peek(f,size+1)) != '>' ) if ( c == EOF ) return 0; else size++; + } + if ( size > 0 ) { + if ( process_possible_link(f, size) ) { + shift(f, size+1); + return 1; + } + else { + int i; + if ( forbidden_tag(f) ) return 0; - Qchar('<', f); - while ( ((c = peek(f, 1)) != EOF) && (c != '>') ) - Qchar(pull(f), f); - return 1; - } - else if ( !isspace(c) && process_possible_link(f, size) ) { + for ( i=0; i <= size+1; i++ ) + Qchar(peek(f, i), f); + shift(f, size+1); return 1; } diff --git a/tests/automatic.t b/tests/automatic.t index c0df571..44c97a7 100644 --- a/tests/automatic.t +++ b/tests/automatic.t @@ -13,11 +13,11 @@ try 'http:foo/bar' '' '

http:foo/bar< try '' '' '

' match '' '' '' '' '' '' '

<orc@>

' +try 'invalid ' '' '

' try 'invalid <@pell>' '<@pell>' '

<@pell>

' -try 'invalid ' '' '

<orc@pell>

' -try 'invalid ' '' '

<orc@.pell>

' -try 'invalid ' '' '

<orc@pell.>

' +try 'invalid ' '' '

' +try 'invalid ' '' '

' +try 'invalid ' '' '

' match '' '' '
' '' '' '' 'content' -try 'github tags disabled by default' \ -"$SRC" \ -'

<element-name>content</element-name>

' +# try 'github tags disabled by default' \ +# "$SRC" \ +# '

<element-name>content</element-name>

' try -fgithubtags 'github tags' \ "$SRC" \ diff --git a/tests/muñoz.t b/tests/muñoz.t index c53f6bf..396bdc1 100644 --- a/tests/muñoz.t +++ b/tests/muñoz.t @@ -105,7 +105,7 @@ try 'id_000177_06' '
00000

' try 'id_000182_06' '

-' '

-

' try 'id_000189_06' '
    #0' '

      #0

      ' -try 'id_000190_06' '

      *' '

      <p/*

      ' +try 'id_000190_06' '

      *' '

      *

      ' try 'id_000192_06' '
      *' '

      *

      ' try 'id_000197_06' '
        0' '

          </u

          @@ -120,7 +120,7 @@ try 'id_000209_06' '00000

          ' try 'id_000211_06' '

          +' '

          +

          ' try 'id_000219_06' '*' '

          *

          ' -try 'id_000222_06' '

          -' '

          <p/-

          ' +try 'id_000222_06' '

          -' '

          -

          ' try -ftabstop 'id_000223_06' '00000' '

          00000

          '