Fossil SCM
Improvements to comment formatting error detection. Added the -m option to the "fossil test-wiki-render" command to help facilitate testing.
Commit
d43f3e2a88f8fca8f2e4cadd86c6025819bcc0fff5268bdf5bc9aa1e18f4677a
Parent
a98056699180979…
1 file changed
+15
-3
+15
-3
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -789,11 +789,14 @@ | ||
| 789 | 789 | int n; |
| 790 | 790 | if( z[0]=='[' ){ |
| 791 | 791 | if( (n = linkLength(z))>0 ){ |
| 792 | 792 | *pTokenType = TOKEN_LINK; |
| 793 | 793 | return n; |
| 794 | - }else{ | |
| 794 | + }else if( p->state & WIKI_MARK ){ | |
| 795 | + blob_append_string(p->pOut, "<mark>"); | |
| 796 | + p->mRender |= RENDER_BADLINK|RENDER_MARK; | |
| 797 | + }else{ | |
| 795 | 798 | p->mRender |= RENDER_BADLINK; |
| 796 | 799 | } |
| 797 | 800 | } |
| 798 | 801 | *pTokenType = TOKEN_RAW; |
| 799 | 802 | return 1 + textLength(z+1, p->state); |
| @@ -1628,12 +1631,14 @@ | ||
| 1628 | 1631 | if( p->state & WIKI_MARK ){ |
| 1629 | 1632 | blob_append_string(p->pOut, "<mark>"); |
| 1630 | 1633 | p->mRender |= RENDER_MARK; |
| 1631 | 1634 | } |
| 1632 | 1635 | if( z[0]=='<' ){ |
| 1636 | + p->mRender |= RENDER_BADTAG; | |
| 1633 | 1637 | blob_append_string(p->pOut, "<"); |
| 1634 | 1638 | }else if( z[0]=='&' ){ |
| 1639 | + p->mRender |= RENDER_BADENTITY; | |
| 1635 | 1640 | blob_append_string(p->pOut, "&"); |
| 1636 | 1641 | } |
| 1637 | 1642 | if( p->state & WIKI_MARK ){ |
| 1638 | 1643 | if( fossil_isalnum(z[1]) || (z[1]=='/' && fossil_isalnum(z[2])) ){ |
| 1639 | 1644 | int kk; |
| @@ -1954,10 +1959,11 @@ | ||
| 1954 | 1959 | ** --dark-pikchr Render pikchrs in dark mode |
| 1955 | 1960 | ** --flow Render as text using comment_format |
| 1956 | 1961 | ** --htmlonly Set the WIKI_HTMLONLY flag |
| 1957 | 1962 | ** --inline Set the WIKI_INLINE flag |
| 1958 | 1963 | ** --linksonly Set the WIKI_LINKSONLY flag |
| 1964 | +** -m TEXT Use TEXT in place of the content of FILE | |
| 1959 | 1965 | ** --mark Add <mark>...</mark> around problems |
| 1960 | 1966 | ** --nobadlinks Set the WIKI_NOBADLINKS flag |
| 1961 | 1967 | ** --text Run the output through html_to_plaintext() |
| 1962 | 1968 | ** --type Break down the return code from wiki_convert() |
| 1963 | 1969 | */ |
| @@ -1966,10 +1972,11 @@ | ||
| 1966 | 1972 | int flags = 0; |
| 1967 | 1973 | int bText; |
| 1968 | 1974 | int bFlow = 0; |
| 1969 | 1975 | int showType = 0; |
| 1970 | 1976 | int mType; |
| 1977 | + const char *zIn; | |
| 1971 | 1978 | if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS; |
| 1972 | 1979 | if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY; |
| 1973 | 1980 | if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY; |
| 1974 | 1981 | if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS; |
| 1975 | 1982 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| @@ -1978,15 +1985,20 @@ | ||
| 1978 | 1985 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1979 | 1986 | } |
| 1980 | 1987 | bText = find_option("text",0,0)!=0; |
| 1981 | 1988 | bFlow = find_option("flow",0,0)!=0; |
| 1982 | 1989 | showType = find_option("type",0,0)!=0; |
| 1990 | + zIn = find_option("msg","m",1); | |
| 1983 | 1991 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1984 | 1992 | verify_all_options(); |
| 1985 | - if( g.argc!=3 ) usage("FILE"); | |
| 1993 | + if( (zIn==0 && g.argc!=3) || (zIn!=0 && g.argc!=2) ) usage("FILE"); | |
| 1986 | 1994 | blob_zero(&out); |
| 1987 | - blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 1995 | + if( zIn ){ | |
| 1996 | + blob_init(&in, zIn, -1); | |
| 1997 | + }else{ | |
| 1998 | + blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 1999 | + } | |
| 1988 | 2000 | mType = wiki_convert(&in, &out, flags); |
| 1989 | 2001 | if( bText ){ |
| 1990 | 2002 | Blob txt; |
| 1991 | 2003 | int htot = 0; |
| 1992 | 2004 | if( terminal_is_vt100() ) htot |= HTOT_VT100; |
| 1993 | 2005 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -789,11 +789,14 @@ | |
| 789 | int n; |
| 790 | if( z[0]=='[' ){ |
| 791 | if( (n = linkLength(z))>0 ){ |
| 792 | *pTokenType = TOKEN_LINK; |
| 793 | return n; |
| 794 | }else{ |
| 795 | p->mRender |= RENDER_BADLINK; |
| 796 | } |
| 797 | } |
| 798 | *pTokenType = TOKEN_RAW; |
| 799 | return 1 + textLength(z+1, p->state); |
| @@ -1628,12 +1631,14 @@ | |
| 1628 | if( p->state & WIKI_MARK ){ |
| 1629 | blob_append_string(p->pOut, "<mark>"); |
| 1630 | p->mRender |= RENDER_MARK; |
| 1631 | } |
| 1632 | if( z[0]=='<' ){ |
| 1633 | blob_append_string(p->pOut, "<"); |
| 1634 | }else if( z[0]=='&' ){ |
| 1635 | blob_append_string(p->pOut, "&"); |
| 1636 | } |
| 1637 | if( p->state & WIKI_MARK ){ |
| 1638 | if( fossil_isalnum(z[1]) || (z[1]=='/' && fossil_isalnum(z[2])) ){ |
| 1639 | int kk; |
| @@ -1954,10 +1959,11 @@ | |
| 1954 | ** --dark-pikchr Render pikchrs in dark mode |
| 1955 | ** --flow Render as text using comment_format |
| 1956 | ** --htmlonly Set the WIKI_HTMLONLY flag |
| 1957 | ** --inline Set the WIKI_INLINE flag |
| 1958 | ** --linksonly Set the WIKI_LINKSONLY flag |
| 1959 | ** --mark Add <mark>...</mark> around problems |
| 1960 | ** --nobadlinks Set the WIKI_NOBADLINKS flag |
| 1961 | ** --text Run the output through html_to_plaintext() |
| 1962 | ** --type Break down the return code from wiki_convert() |
| 1963 | */ |
| @@ -1966,10 +1972,11 @@ | |
| 1966 | int flags = 0; |
| 1967 | int bText; |
| 1968 | int bFlow = 0; |
| 1969 | int showType = 0; |
| 1970 | int mType; |
| 1971 | if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS; |
| 1972 | if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY; |
| 1973 | if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY; |
| 1974 | if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS; |
| 1975 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| @@ -1978,15 +1985,20 @@ | |
| 1978 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1979 | } |
| 1980 | bText = find_option("text",0,0)!=0; |
| 1981 | bFlow = find_option("flow",0,0)!=0; |
| 1982 | showType = find_option("type",0,0)!=0; |
| 1983 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1984 | verify_all_options(); |
| 1985 | if( g.argc!=3 ) usage("FILE"); |
| 1986 | blob_zero(&out); |
| 1987 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1988 | mType = wiki_convert(&in, &out, flags); |
| 1989 | if( bText ){ |
| 1990 | Blob txt; |
| 1991 | int htot = 0; |
| 1992 | if( terminal_is_vt100() ) htot |= HTOT_VT100; |
| 1993 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -789,11 +789,14 @@ | |
| 789 | int n; |
| 790 | if( z[0]=='[' ){ |
| 791 | if( (n = linkLength(z))>0 ){ |
| 792 | *pTokenType = TOKEN_LINK; |
| 793 | return n; |
| 794 | }else if( p->state & WIKI_MARK ){ |
| 795 | blob_append_string(p->pOut, "<mark>"); |
| 796 | p->mRender |= RENDER_BADLINK|RENDER_MARK; |
| 797 | }else{ |
| 798 | p->mRender |= RENDER_BADLINK; |
| 799 | } |
| 800 | } |
| 801 | *pTokenType = TOKEN_RAW; |
| 802 | return 1 + textLength(z+1, p->state); |
| @@ -1628,12 +1631,14 @@ | |
| 1631 | if( p->state & WIKI_MARK ){ |
| 1632 | blob_append_string(p->pOut, "<mark>"); |
| 1633 | p->mRender |= RENDER_MARK; |
| 1634 | } |
| 1635 | if( z[0]=='<' ){ |
| 1636 | p->mRender |= RENDER_BADTAG; |
| 1637 | blob_append_string(p->pOut, "<"); |
| 1638 | }else if( z[0]=='&' ){ |
| 1639 | p->mRender |= RENDER_BADENTITY; |
| 1640 | blob_append_string(p->pOut, "&"); |
| 1641 | } |
| 1642 | if( p->state & WIKI_MARK ){ |
| 1643 | if( fossil_isalnum(z[1]) || (z[1]=='/' && fossil_isalnum(z[2])) ){ |
| 1644 | int kk; |
| @@ -1954,10 +1959,11 @@ | |
| 1959 | ** --dark-pikchr Render pikchrs in dark mode |
| 1960 | ** --flow Render as text using comment_format |
| 1961 | ** --htmlonly Set the WIKI_HTMLONLY flag |
| 1962 | ** --inline Set the WIKI_INLINE flag |
| 1963 | ** --linksonly Set the WIKI_LINKSONLY flag |
| 1964 | ** -m TEXT Use TEXT in place of the content of FILE |
| 1965 | ** --mark Add <mark>...</mark> around problems |
| 1966 | ** --nobadlinks Set the WIKI_NOBADLINKS flag |
| 1967 | ** --text Run the output through html_to_plaintext() |
| 1968 | ** --type Break down the return code from wiki_convert() |
| 1969 | */ |
| @@ -1966,10 +1972,11 @@ | |
| 1972 | int flags = 0; |
| 1973 | int bText; |
| 1974 | int bFlow = 0; |
| 1975 | int showType = 0; |
| 1976 | int mType; |
| 1977 | const char *zIn; |
| 1978 | if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS; |
| 1979 | if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY; |
| 1980 | if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY; |
| 1981 | if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS; |
| 1982 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| @@ -1978,15 +1985,20 @@ | |
| 1985 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1986 | } |
| 1987 | bText = find_option("text",0,0)!=0; |
| 1988 | bFlow = find_option("flow",0,0)!=0; |
| 1989 | showType = find_option("type",0,0)!=0; |
| 1990 | zIn = find_option("msg","m",1); |
| 1991 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1992 | verify_all_options(); |
| 1993 | if( (zIn==0 && g.argc!=3) || (zIn!=0 && g.argc!=2) ) usage("FILE"); |
| 1994 | blob_zero(&out); |
| 1995 | if( zIn ){ |
| 1996 | blob_init(&in, zIn, -1); |
| 1997 | }else{ |
| 1998 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1999 | } |
| 2000 | mType = wiki_convert(&in, &out, flags); |
| 2001 | if( bText ){ |
| 2002 | Blob txt; |
| 2003 | int htot = 0; |
| 2004 | if( terminal_is_vt100() ) htot |= HTOT_VT100; |
| 2005 |