Fossil SCM

Improvements to comment formatting error detection. Added the -m option to the "fossil test-wiki-render" command to help facilitate testing.

drh 2025-03-22 11:55 trunk
Commit d43f3e2a88f8fca8f2e4cadd86c6025819bcc0fff5268bdf5bc9aa1e18f4677a
1 file changed +15 -3
+15 -3
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -789,11 +789,14 @@
789789
int n;
790790
if( z[0]=='[' ){
791791
if( (n = linkLength(z))>0 ){
792792
*pTokenType = TOKEN_LINK;
793793
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{
795798
p->mRender |= RENDER_BADLINK;
796799
}
797800
}
798801
*pTokenType = TOKEN_RAW;
799802
return 1 + textLength(z+1, p->state);
@@ -1628,12 +1631,14 @@
16281631
if( p->state & WIKI_MARK ){
16291632
blob_append_string(p->pOut, "<mark>");
16301633
p->mRender |= RENDER_MARK;
16311634
}
16321635
if( z[0]=='<' ){
1636
+ p->mRender |= RENDER_BADTAG;
16331637
blob_append_string(p->pOut, "&lt;");
16341638
}else if( z[0]=='&' ){
1639
+ p->mRender |= RENDER_BADENTITY;
16351640
blob_append_string(p->pOut, "&amp;");
16361641
}
16371642
if( p->state & WIKI_MARK ){
16381643
if( fossil_isalnum(z[1]) || (z[1]=='/' && fossil_isalnum(z[2])) ){
16391644
int kk;
@@ -1954,10 +1959,11 @@
19541959
** --dark-pikchr Render pikchrs in dark mode
19551960
** --flow Render as text using comment_format
19561961
** --htmlonly Set the WIKI_HTMLONLY flag
19571962
** --inline Set the WIKI_INLINE flag
19581963
** --linksonly Set the WIKI_LINKSONLY flag
1964
+** -m TEXT Use TEXT in place of the content of FILE
19591965
** --mark Add <mark>...</mark> around problems
19601966
** --nobadlinks Set the WIKI_NOBADLINKS flag
19611967
** --text Run the output through html_to_plaintext()
19621968
** --type Break down the return code from wiki_convert()
19631969
*/
@@ -1966,10 +1972,11 @@
19661972
int flags = 0;
19671973
int bText;
19681974
int bFlow = 0;
19691975
int showType = 0;
19701976
int mType;
1977
+ const char *zIn;
19711978
if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS;
19721979
if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY;
19731980
if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY;
19741981
if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS;
19751982
if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE;
@@ -1978,15 +1985,20 @@
19781985
pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE );
19791986
}
19801987
bText = find_option("text",0,0)!=0;
19811988
bFlow = find_option("flow",0,0)!=0;
19821989
showType = find_option("type",0,0)!=0;
1990
+ zIn = find_option("msg","m",1);
19831991
db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
19841992
verify_all_options();
1985
- if( g.argc!=3 ) usage("FILE");
1993
+ if( (zIn==0 && g.argc!=3) || (zIn!=0 && g.argc!=2) ) usage("FILE");
19861994
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
+ }
19882000
mType = wiki_convert(&in, &out, flags);
19892001
if( bText ){
19902002
Blob txt;
19912003
int htot = 0;
19922004
if( terminal_is_vt100() ) htot |= HTOT_VT100;
19932005
--- 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, "&lt;");
1634 }else if( z[0]=='&' ){
 
1635 blob_append_string(p->pOut, "&amp;");
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, "&lt;");
1638 }else if( z[0]=='&' ){
1639 p->mRender |= RENDER_BADENTITY;
1640 blob_append_string(p->pOut, "&amp;");
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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button