Fossil SCM
Add the --text option to test-wiki-render and test-markdown-render.
Commit
3ea3cd5ca50838a2d1be3fdd6200e0a03e5916022735599df4a6f7aa8d8fd6f0
Parent
2b2bc057f6a8ce7…
1 file changed
+24
-5
+24
-5
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -1870,35 +1870,45 @@ | ||
| 1870 | 1870 | ** Translate the input FILE from Fossil-wiki into HTML and write |
| 1871 | 1871 | ** the resulting HTML on standard output. |
| 1872 | 1872 | ** |
| 1873 | 1873 | ** Options: |
| 1874 | 1874 | ** --buttons Set the WIKI_BUTTONS flag |
| 1875 | +** --dark-pikchr Render pikchrs in dark mode | |
| 1875 | 1876 | ** --htmlonly Set the WIKI_HTMLONLY flag |
| 1877 | +** --inline Set the WIKI_INLINE flag | |
| 1876 | 1878 | ** --linksonly Set the WIKI_LINKSONLY flag |
| 1877 | 1879 | ** --nobadlinks Set the WIKI_NOBADLINKS flag |
| 1878 | -** --inline Set the WIKI_INLINE flag | |
| 1879 | 1880 | ** --noblock Set the WIKI_NOBLOCK flag |
| 1880 | -** --dark-pikchr Render pikchrs in dark mode | |
| 1881 | +** --text Run the output through html_to_plaintext(). | |
| 1881 | 1882 | */ |
| 1882 | 1883 | void test_wiki_render(void){ |
| 1883 | 1884 | Blob in, out; |
| 1884 | 1885 | int flags = 0; |
| 1886 | + int bText; | |
| 1885 | 1887 | if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS; |
| 1886 | 1888 | if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY; |
| 1887 | 1889 | if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY; |
| 1888 | 1890 | if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS; |
| 1889 | 1891 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| 1890 | 1892 | if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK; |
| 1891 | 1893 | if( find_option("dark-pikchr",0,0)!=0 ){ |
| 1892 | 1894 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1893 | 1895 | } |
| 1896 | + bText = find_option("text",0,0)!=0; | |
| 1894 | 1897 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1895 | 1898 | verify_all_options(); |
| 1896 | 1899 | if( g.argc!=3 ) usage("FILE"); |
| 1897 | 1900 | blob_zero(&out); |
| 1898 | 1901 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1899 | 1902 | wiki_convert(&in, &out, flags); |
| 1903 | + if( bText ){ | |
| 1904 | + Blob txt; | |
| 1905 | + blob_init(&txt, 0, 0); | |
| 1906 | + html_to_plaintext(blob_str(&out),&txt); | |
| 1907 | + blob_reset(&out); | |
| 1908 | + out = txt; | |
| 1909 | + } | |
| 1900 | 1910 | blob_write_to_file(&out, "-"); |
| 1901 | 1911 | } |
| 1902 | 1912 | |
| 1903 | 1913 | /* |
| 1904 | 1914 | ** COMMAND: test-markdown-render |
| @@ -1906,24 +1916,26 @@ | ||
| 1906 | 1916 | ** Usage: %fossil test-markdown-render FILE ... |
| 1907 | 1917 | ** |
| 1908 | 1918 | ** Render markdown in FILE as HTML on stdout. |
| 1909 | 1919 | ** Options: |
| 1910 | 1920 | ** |
| 1911 | -** --safe Restrict the output to use only "safe" HTML | |
| 1921 | +** --dark-pikchr Render pikchrs in dark mode | |
| 1912 | 1922 | ** --lint-footnotes Print stats for footnotes-related issues |
| 1913 | -** --dark-pikchr Render pikchrs in dark mode | |
| 1923 | +** --safe Restrict the output to use only "safe" HTML | |
| 1924 | +** --text Run the output through html_to_plaintext(). | |
| 1914 | 1925 | */ |
| 1915 | 1926 | void test_markdown_render(void){ |
| 1916 | 1927 | Blob in, out; |
| 1917 | 1928 | int i; |
| 1918 | - int bSafe = 0, bFnLint = 0; | |
| 1929 | + int bSafe = 0, bFnLint = 0, bText = 0; | |
| 1919 | 1930 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1920 | 1931 | bSafe = find_option("safe",0,0)!=0; |
| 1921 | 1932 | bFnLint = find_option("lint-footnotes",0,0)!=0; |
| 1922 | 1933 | if( find_option("dark-pikchr",0,0)!=0 ){ |
| 1923 | 1934 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1924 | 1935 | } |
| 1936 | + bText = find_option("text",0,0)!=0; | |
| 1925 | 1937 | verify_all_options(); |
| 1926 | 1938 | for(i=2; i<g.argc; i++){ |
| 1927 | 1939 | blob_zero(&out); |
| 1928 | 1940 | blob_read_from_file(&in, g.argv[i], ExtFILE); |
| 1929 | 1941 | if( g.argc>3 ){ |
| @@ -1930,10 +1942,17 @@ | ||
| 1930 | 1942 | fossil_print("<!------ %h ------->\n", g.argv[i]); |
| 1931 | 1943 | } |
| 1932 | 1944 | markdown_to_html(&in, 0, &out); |
| 1933 | 1945 | safe_html_context( bSafe ? DOCSRC_UNTRUSTED : DOCSRC_TRUSTED ); |
| 1934 | 1946 | safe_html(&out); |
| 1947 | + if( bText ){ | |
| 1948 | + Blob txt; | |
| 1949 | + blob_init(&txt, 0, 0); | |
| 1950 | + html_to_plaintext(blob_str(&out), &txt); | |
| 1951 | + blob_reset(&out); | |
| 1952 | + out = txt; | |
| 1953 | + } | |
| 1935 | 1954 | blob_write_to_file(&out, "-"); |
| 1936 | 1955 | blob_reset(&in); |
| 1937 | 1956 | blob_reset(&out); |
| 1938 | 1957 | } |
| 1939 | 1958 | if( bFnLint && (g.ftntsIssues[0] || g.ftntsIssues[1] |
| 1940 | 1959 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -1870,35 +1870,45 @@ | |
| 1870 | ** Translate the input FILE from Fossil-wiki into HTML and write |
| 1871 | ** the resulting HTML on standard output. |
| 1872 | ** |
| 1873 | ** Options: |
| 1874 | ** --buttons Set the WIKI_BUTTONS flag |
| 1875 | ** --htmlonly Set the WIKI_HTMLONLY flag |
| 1876 | ** --linksonly Set the WIKI_LINKSONLY flag |
| 1877 | ** --nobadlinks Set the WIKI_NOBADLINKS flag |
| 1878 | ** --inline Set the WIKI_INLINE flag |
| 1879 | ** --noblock Set the WIKI_NOBLOCK flag |
| 1880 | ** --dark-pikchr Render pikchrs in dark mode |
| 1881 | */ |
| 1882 | void test_wiki_render(void){ |
| 1883 | Blob in, out; |
| 1884 | int flags = 0; |
| 1885 | if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS; |
| 1886 | if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY; |
| 1887 | if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY; |
| 1888 | if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS; |
| 1889 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| 1890 | if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK; |
| 1891 | if( find_option("dark-pikchr",0,0)!=0 ){ |
| 1892 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1893 | } |
| 1894 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1895 | verify_all_options(); |
| 1896 | if( g.argc!=3 ) usage("FILE"); |
| 1897 | blob_zero(&out); |
| 1898 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1899 | wiki_convert(&in, &out, flags); |
| 1900 | blob_write_to_file(&out, "-"); |
| 1901 | } |
| 1902 | |
| 1903 | /* |
| 1904 | ** COMMAND: test-markdown-render |
| @@ -1906,24 +1916,26 @@ | |
| 1906 | ** Usage: %fossil test-markdown-render FILE ... |
| 1907 | ** |
| 1908 | ** Render markdown in FILE as HTML on stdout. |
| 1909 | ** Options: |
| 1910 | ** |
| 1911 | ** --safe Restrict the output to use only "safe" HTML |
| 1912 | ** --lint-footnotes Print stats for footnotes-related issues |
| 1913 | ** --dark-pikchr Render pikchrs in dark mode |
| 1914 | */ |
| 1915 | void test_markdown_render(void){ |
| 1916 | Blob in, out; |
| 1917 | int i; |
| 1918 | int bSafe = 0, bFnLint = 0; |
| 1919 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1920 | bSafe = find_option("safe",0,0)!=0; |
| 1921 | bFnLint = find_option("lint-footnotes",0,0)!=0; |
| 1922 | if( find_option("dark-pikchr",0,0)!=0 ){ |
| 1923 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1924 | } |
| 1925 | verify_all_options(); |
| 1926 | for(i=2; i<g.argc; i++){ |
| 1927 | blob_zero(&out); |
| 1928 | blob_read_from_file(&in, g.argv[i], ExtFILE); |
| 1929 | if( g.argc>3 ){ |
| @@ -1930,10 +1942,17 @@ | |
| 1930 | fossil_print("<!------ %h ------->\n", g.argv[i]); |
| 1931 | } |
| 1932 | markdown_to_html(&in, 0, &out); |
| 1933 | safe_html_context( bSafe ? DOCSRC_UNTRUSTED : DOCSRC_TRUSTED ); |
| 1934 | safe_html(&out); |
| 1935 | blob_write_to_file(&out, "-"); |
| 1936 | blob_reset(&in); |
| 1937 | blob_reset(&out); |
| 1938 | } |
| 1939 | if( bFnLint && (g.ftntsIssues[0] || g.ftntsIssues[1] |
| 1940 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -1870,35 +1870,45 @@ | |
| 1870 | ** Translate the input FILE from Fossil-wiki into HTML and write |
| 1871 | ** the resulting HTML on standard output. |
| 1872 | ** |
| 1873 | ** Options: |
| 1874 | ** --buttons Set the WIKI_BUTTONS flag |
| 1875 | ** --dark-pikchr Render pikchrs in dark mode |
| 1876 | ** --htmlonly Set the WIKI_HTMLONLY flag |
| 1877 | ** --inline Set the WIKI_INLINE flag |
| 1878 | ** --linksonly Set the WIKI_LINKSONLY flag |
| 1879 | ** --nobadlinks Set the WIKI_NOBADLINKS flag |
| 1880 | ** --noblock Set the WIKI_NOBLOCK flag |
| 1881 | ** --text Run the output through html_to_plaintext(). |
| 1882 | */ |
| 1883 | void test_wiki_render(void){ |
| 1884 | Blob in, out; |
| 1885 | int flags = 0; |
| 1886 | int bText; |
| 1887 | if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS; |
| 1888 | if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY; |
| 1889 | if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY; |
| 1890 | if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS; |
| 1891 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| 1892 | if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK; |
| 1893 | if( find_option("dark-pikchr",0,0)!=0 ){ |
| 1894 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1895 | } |
| 1896 | bText = find_option("text",0,0)!=0; |
| 1897 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1898 | verify_all_options(); |
| 1899 | if( g.argc!=3 ) usage("FILE"); |
| 1900 | blob_zero(&out); |
| 1901 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1902 | wiki_convert(&in, &out, flags); |
| 1903 | if( bText ){ |
| 1904 | Blob txt; |
| 1905 | blob_init(&txt, 0, 0); |
| 1906 | html_to_plaintext(blob_str(&out),&txt); |
| 1907 | blob_reset(&out); |
| 1908 | out = txt; |
| 1909 | } |
| 1910 | blob_write_to_file(&out, "-"); |
| 1911 | } |
| 1912 | |
| 1913 | /* |
| 1914 | ** COMMAND: test-markdown-render |
| @@ -1906,24 +1916,26 @@ | |
| 1916 | ** Usage: %fossil test-markdown-render FILE ... |
| 1917 | ** |
| 1918 | ** Render markdown in FILE as HTML on stdout. |
| 1919 | ** Options: |
| 1920 | ** |
| 1921 | ** --dark-pikchr Render pikchrs in dark mode |
| 1922 | ** --lint-footnotes Print stats for footnotes-related issues |
| 1923 | ** --safe Restrict the output to use only "safe" HTML |
| 1924 | ** --text Run the output through html_to_plaintext(). |
| 1925 | */ |
| 1926 | void test_markdown_render(void){ |
| 1927 | Blob in, out; |
| 1928 | int i; |
| 1929 | int bSafe = 0, bFnLint = 0, bText = 0; |
| 1930 | db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0); |
| 1931 | bSafe = find_option("safe",0,0)!=0; |
| 1932 | bFnLint = find_option("lint-footnotes",0,0)!=0; |
| 1933 | if( find_option("dark-pikchr",0,0)!=0 ){ |
| 1934 | pikchr_to_html_add_flags( PIKCHR_PROCESS_DARK_MODE ); |
| 1935 | } |
| 1936 | bText = find_option("text",0,0)!=0; |
| 1937 | verify_all_options(); |
| 1938 | for(i=2; i<g.argc; i++){ |
| 1939 | blob_zero(&out); |
| 1940 | blob_read_from_file(&in, g.argv[i], ExtFILE); |
| 1941 | if( g.argc>3 ){ |
| @@ -1930,10 +1942,17 @@ | |
| 1942 | fossil_print("<!------ %h ------->\n", g.argv[i]); |
| 1943 | } |
| 1944 | markdown_to_html(&in, 0, &out); |
| 1945 | safe_html_context( bSafe ? DOCSRC_UNTRUSTED : DOCSRC_TRUSTED ); |
| 1946 | safe_html(&out); |
| 1947 | if( bText ){ |
| 1948 | Blob txt; |
| 1949 | blob_init(&txt, 0, 0); |
| 1950 | html_to_plaintext(blob_str(&out), &txt); |
| 1951 | blob_reset(&out); |
| 1952 | out = txt; |
| 1953 | } |
| 1954 | blob_write_to_file(&out, "-"); |
| 1955 | blob_reset(&in); |
| 1956 | blob_reset(&out); |
| 1957 | } |
| 1958 | if( bFnLint && (g.ftntsIssues[0] || g.ftntsIssues[1] |
| 1959 |