Fossil SCM
The <mark> HTML tag flows through to the output in html_to_plaintext() if the output is not going to a VT-100 terminal.
Commit
a9805669918097942759f44935fd79cb6c2c365eb008a9649d2a82be9595fb80
Parent
0432c38df681ecc…
1 file changed
+19
-9
+19
-9
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -2524,10 +2524,22 @@ | ||
| 2524 | 2524 | */ |
| 2525 | 2525 | #define HTOT_VT100 0x0001 /* <mark> becomes ^[[91m */ |
| 2526 | 2526 | #define HTOT_NO_WS 0x0002 /* Collapse whitespace to a single space */ |
| 2527 | 2527 | |
| 2528 | 2528 | #endif /* INTERFACE */ |
| 2529 | + | |
| 2530 | +/* | |
| 2531 | +** Add <MARK> or </MARK> to the output, or similar VT-100 escape | |
| 2532 | +** codes. | |
| 2533 | +*/ | |
| 2534 | +static void addMark(Blob *pOut, int mFlags, int isClose){ | |
| 2535 | + static const char *az[4] = { "<MARK>", "</MARK>", "\033[91m", "\033[0m" }; | |
| 2536 | + int i = 0; | |
| 2537 | + if( isClose ) i++; | |
| 2538 | + if( mFlags & HTOT_VT100 ) i += 2; | |
| 2539 | + blob_append(pOut, az[i], -1); | |
| 2540 | +} | |
| 2529 | 2541 | |
| 2530 | 2542 | /* |
| 2531 | 2543 | ** Remove all HTML markup from the input text. The output written into |
| 2532 | 2544 | ** pOut is pure text. |
| 2533 | 2545 | ** |
| @@ -2568,18 +2580,16 @@ | ||
| 2568 | 2580 | } |
| 2569 | 2581 | if( zIn[0]=='<' ) zIn += n; |
| 2570 | 2582 | continue; |
| 2571 | 2583 | } |
| 2572 | 2584 | if( eTag==MARKUP_INVALID && strcmp(zTag,"mark")==0 ){ |
| 2573 | - if( (mFlags & HTOT_VT100)!=0 ){ | |
| 2574 | - if( isCloseTag && nMark ){ | |
| 2575 | - blob_append(pOut, "\033[0m", 4); | |
| 2576 | - nMark = 0; | |
| 2577 | - }else if( !isCloseTag && !nMark ){ | |
| 2578 | - blob_append(pOut, "\033[91m", 5); | |
| 2579 | - nMark = 1; | |
| 2580 | - } | |
| 2585 | + if( isCloseTag && nMark ){ | |
| 2586 | + addMark(pOut, mFlags, 1); | |
| 2587 | + nMark = 0; | |
| 2588 | + }else if( !isCloseTag && !nMark ){ | |
| 2589 | + addMark(pOut, mFlags, 0); | |
| 2590 | + nMark = 1; | |
| 2581 | 2591 | } |
| 2582 | 2592 | zIn += n; |
| 2583 | 2593 | continue; |
| 2584 | 2594 | } |
| 2585 | 2595 | if( eTag==MARKUP_TITLE ){ |
| @@ -2658,11 +2668,11 @@ | ||
| 2658 | 2668 | nNL = nWS = 0; |
| 2659 | 2669 | blob_append(pOut, zIn, n); |
| 2660 | 2670 | } |
| 2661 | 2671 | zIn += n; |
| 2662 | 2672 | } |
| 2663 | - if( nMark ) blob_append(pOut, "\033[0m", 4); | |
| 2673 | + if( nMark ) addMark(pOut, mFlags, 1); | |
| 2664 | 2674 | if( nNL==0 ) blob_append_char(pOut, '\n'); |
| 2665 | 2675 | } |
| 2666 | 2676 | |
| 2667 | 2677 | /* |
| 2668 | 2678 | ** COMMAND: test-html-to-text |
| 2669 | 2679 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -2524,10 +2524,22 @@ | |
| 2524 | */ |
| 2525 | #define HTOT_VT100 0x0001 /* <mark> becomes ^[[91m */ |
| 2526 | #define HTOT_NO_WS 0x0002 /* Collapse whitespace to a single space */ |
| 2527 | |
| 2528 | #endif /* INTERFACE */ |
| 2529 | |
| 2530 | /* |
| 2531 | ** Remove all HTML markup from the input text. The output written into |
| 2532 | ** pOut is pure text. |
| 2533 | ** |
| @@ -2568,18 +2580,16 @@ | |
| 2568 | } |
| 2569 | if( zIn[0]=='<' ) zIn += n; |
| 2570 | continue; |
| 2571 | } |
| 2572 | if( eTag==MARKUP_INVALID && strcmp(zTag,"mark")==0 ){ |
| 2573 | if( (mFlags & HTOT_VT100)!=0 ){ |
| 2574 | if( isCloseTag && nMark ){ |
| 2575 | blob_append(pOut, "\033[0m", 4); |
| 2576 | nMark = 0; |
| 2577 | }else if( !isCloseTag && !nMark ){ |
| 2578 | blob_append(pOut, "\033[91m", 5); |
| 2579 | nMark = 1; |
| 2580 | } |
| 2581 | } |
| 2582 | zIn += n; |
| 2583 | continue; |
| 2584 | } |
| 2585 | if( eTag==MARKUP_TITLE ){ |
| @@ -2658,11 +2668,11 @@ | |
| 2658 | nNL = nWS = 0; |
| 2659 | blob_append(pOut, zIn, n); |
| 2660 | } |
| 2661 | zIn += n; |
| 2662 | } |
| 2663 | if( nMark ) blob_append(pOut, "\033[0m", 4); |
| 2664 | if( nNL==0 ) blob_append_char(pOut, '\n'); |
| 2665 | } |
| 2666 | |
| 2667 | /* |
| 2668 | ** COMMAND: test-html-to-text |
| 2669 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -2524,10 +2524,22 @@ | |
| 2524 | */ |
| 2525 | #define HTOT_VT100 0x0001 /* <mark> becomes ^[[91m */ |
| 2526 | #define HTOT_NO_WS 0x0002 /* Collapse whitespace to a single space */ |
| 2527 | |
| 2528 | #endif /* INTERFACE */ |
| 2529 | |
| 2530 | /* |
| 2531 | ** Add <MARK> or </MARK> to the output, or similar VT-100 escape |
| 2532 | ** codes. |
| 2533 | */ |
| 2534 | static void addMark(Blob *pOut, int mFlags, int isClose){ |
| 2535 | static const char *az[4] = { "<MARK>", "</MARK>", "\033[91m", "\033[0m" }; |
| 2536 | int i = 0; |
| 2537 | if( isClose ) i++; |
| 2538 | if( mFlags & HTOT_VT100 ) i += 2; |
| 2539 | blob_append(pOut, az[i], -1); |
| 2540 | } |
| 2541 | |
| 2542 | /* |
| 2543 | ** Remove all HTML markup from the input text. The output written into |
| 2544 | ** pOut is pure text. |
| 2545 | ** |
| @@ -2568,18 +2580,16 @@ | |
| 2580 | } |
| 2581 | if( zIn[0]=='<' ) zIn += n; |
| 2582 | continue; |
| 2583 | } |
| 2584 | if( eTag==MARKUP_INVALID && strcmp(zTag,"mark")==0 ){ |
| 2585 | if( isCloseTag && nMark ){ |
| 2586 | addMark(pOut, mFlags, 1); |
| 2587 | nMark = 0; |
| 2588 | }else if( !isCloseTag && !nMark ){ |
| 2589 | addMark(pOut, mFlags, 0); |
| 2590 | nMark = 1; |
| 2591 | } |
| 2592 | zIn += n; |
| 2593 | continue; |
| 2594 | } |
| 2595 | if( eTag==MARKUP_TITLE ){ |
| @@ -2658,11 +2668,11 @@ | |
| 2668 | nNL = nWS = 0; |
| 2669 | blob_append(pOut, zIn, n); |
| 2670 | } |
| 2671 | zIn += n; |
| 2672 | } |
| 2673 | if( nMark ) addMark(pOut, mFlags, 1); |
| 2674 | if( nNL==0 ) blob_append_char(pOut, '\n'); |
| 2675 | } |
| 2676 | |
| 2677 | /* |
| 2678 | ** COMMAND: test-html-to-text |
| 2679 |