Fossil SCM

Extend test-chat-formatter to be able to render both wiki and markdown.

stephan 2024-06-30 09:59 fts5-chat-search
Commit 09ee2c8e718a8a05e767442841c0feffce621511d6a374c71ff5931b6c928de8
1 file changed +9 -4
+9 -4
--- src/chat.c
+++ src/chat.c
@@ -506,25 +506,30 @@
506506
}
507507
508508
/*
509509
** COMMAND: test-chat-formatter
510510
**
511
-** Usage: %fossil test-chat-formatter STRING ...
511
+** Usage: %fossil test-chat-formatter ?OPTIONS? STRING ...
512512
**
513513
** Transform each argument string into HTML that will display the
514514
** chat message. This is used to test the formatter and to verify
515515
** that a malicious message text will not cause HTML or JS injection
516516
** into the chat display in a browser.
517
+**
518
+** Options:
519
+**
520
+** -w|--wiki Assume fossil wiki format instead of markdown
517521
*/
518522
void chat_test_formatter_cmd(void){
519523
int i;
520524
char *zOut;
525
+ int const isWiki = find_option("w","wiki",0)!=0;
521526
db_find_and_open_repository(0,0);
522527
g.perm.Hyperlink = 1;
523
- for(i=0; i<g.argc; i++){
524
- zOut = chat_format_to_html(g.argv[i], 0);
525
- fossil_print("[%d]: %s\n", i, zOut);
528
+ for(i=2; i<g.argc; i++){
529
+ zOut = chat_format_to_html(g.argv[i], isWiki);
530
+ fossil_print("[%d]: %s\n", i-1, zOut);
526531
fossil_free(zOut);
527532
}
528533
}
529534
530535
/*
531536
--- src/chat.c
+++ src/chat.c
@@ -506,25 +506,30 @@
506 }
507
508 /*
509 ** COMMAND: test-chat-formatter
510 **
511 ** Usage: %fossil test-chat-formatter STRING ...
512 **
513 ** Transform each argument string into HTML that will display the
514 ** chat message. This is used to test the formatter and to verify
515 ** that a malicious message text will not cause HTML or JS injection
516 ** into the chat display in a browser.
 
 
 
 
517 */
518 void chat_test_formatter_cmd(void){
519 int i;
520 char *zOut;
 
521 db_find_and_open_repository(0,0);
522 g.perm.Hyperlink = 1;
523 for(i=0; i<g.argc; i++){
524 zOut = chat_format_to_html(g.argv[i], 0);
525 fossil_print("[%d]: %s\n", i, zOut);
526 fossil_free(zOut);
527 }
528 }
529
530 /*
531
--- src/chat.c
+++ src/chat.c
@@ -506,25 +506,30 @@
506 }
507
508 /*
509 ** COMMAND: test-chat-formatter
510 **
511 ** Usage: %fossil test-chat-formatter ?OPTIONS? STRING ...
512 **
513 ** Transform each argument string into HTML that will display the
514 ** chat message. This is used to test the formatter and to verify
515 ** that a malicious message text will not cause HTML or JS injection
516 ** into the chat display in a browser.
517 **
518 ** Options:
519 **
520 ** -w|--wiki Assume fossil wiki format instead of markdown
521 */
522 void chat_test_formatter_cmd(void){
523 int i;
524 char *zOut;
525 int const isWiki = find_option("w","wiki",0)!=0;
526 db_find_and_open_repository(0,0);
527 g.perm.Hyperlink = 1;
528 for(i=2; i<g.argc; i++){
529 zOut = chat_format_to_html(g.argv[i], isWiki);
530 fossil_print("[%d]: %s\n", i-1, zOut);
531 fossil_free(zOut);
532 }
533 }
534
535 /*
536

Keyboard Shortcuts

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