Fossil

Diff
Login

Differences From Artifact [0d93bfe3db]:

To Artifact [ac97f1e894]:


787
788
789
790
791
792
793



794

795
796
797
798
799
800
801
787
788
789
790
791
792
793
794
795
796

797
798
799
800
801
802
803
804







+
+
+
-
+







*/
static int nextRawToken(const char *z, Renderer *p, int *pTokenType){
  int n;
  if( z[0]=='[' ){
    if( (n = linkLength(z))>0 ){
      *pTokenType = TOKEN_LINK;
      return n;
   }else if( p->state & WIKI_MARK ){
     blob_append_string(p->pOut, "<mark>");
     p->mRender |= RENDER_BADLINK|RENDER_MARK;
    }else{
   }else{
      p->mRender |= RENDER_BADLINK;
    }
  }
  *pTokenType = TOKEN_RAW;
  return 1 + textLength(z+1, p->state);
}

1626
1627
1628
1629
1630
1631
1632

1633
1634

1635
1636
1637
1638
1639
1640
1641
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646







+


+







      case TOKEN_CHARACTER: {
        startAutoParagraph(p);
        if( p->state & WIKI_MARK ){
          blob_append_string(p->pOut, "<mark>");
          p->mRender |= RENDER_MARK;
        }
        if( z[0]=='<' ){
          p->mRender |= RENDER_BADTAG;
          blob_append_string(p->pOut, "&lt;");
        }else if( z[0]=='&' ){
          p->mRender |= RENDER_BADENTITY;
          blob_append_string(p->pOut, "&amp;");
        }
        if( p->state & WIKI_MARK ){
          if( fossil_isalnum(z[1]) || (z[1]=='/' && fossil_isalnum(z[2])) ){
            int kk;
            for(kk=2; fossil_isalnum(z[kk]); kk++){}
            blob_append(p->pOut, &z[1], kk-1);
1952
1953
1954
1955
1956
1957
1958

1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970

1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982

1983
1984
1985

1986



1987


1988
1989
1990
1991
1992
1993
1994
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992

1993
1994
1995
1996
1997

1998
1999
2000
2001
2002
2003
2004
2005
2006







+












+












+


-
+

+
+
+
-
+
+







** Options:
**    --buttons        Set the WIKI_BUTTONS flag
**    --dark-pikchr    Render pikchrs in dark mode
**    --flow           Render as text using comment_format
**    --htmlonly       Set the WIKI_HTMLONLY flag
**    --inline         Set the WIKI_INLINE flag
**    --linksonly      Set the WIKI_LINKSONLY flag
**    -m TEXT          Use TEXT in place of the content of FILE
**    --mark           Add <mark>...</mark> around problems
**    --nobadlinks     Set the WIKI_NOBADLINKS flag
**    --text           Run the output through html_to_plaintext()
**    --type           Break down the return code from wiki_convert()
*/
void test_wiki_render(void){
  Blob in, out;
  int flags = 0;
  int bText;
  int bFlow = 0;
  int showType = 0;
  int mType;
  const char *zIn;
  if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS;
  if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY;
  if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY;
  if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS;
  if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE;
  if( find_option("mark",0,0)!=0 ) flags |= WIKI_MARK;
  if( find_option("dark-pikchr",0,0)!=0 ){
    pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE );
  }
  bText = find_option("text",0,0)!=0;
  bFlow = find_option("flow",0,0)!=0;
  showType = find_option("type",0,0)!=0;
  zIn = find_option("msg","m",1);
  db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
  verify_all_options();
  if( g.argc!=3 ) usage("FILE");
  if( (zIn==0 && g.argc!=3) || (zIn!=0 && g.argc!=2) ) usage("FILE");
  blob_zero(&out);
  if( zIn ){
    blob_init(&in, zIn, -1);
  }else{
  blob_read_from_file(&in, g.argv[2], ExtFILE);
    blob_read_from_file(&in, g.argv[2], ExtFILE);
  }
  mType = wiki_convert(&in, &out, flags);
  if( bText ){
    Blob txt;
    int htot = 0;
    if( terminal_is_vt100() ) htot |= HTOT_VT100;
    if( bFlow ) htot |= HTOT_NO_WS;
    blob_init(&txt, 0, 0);