Welcome to little lamb

Code » md4c » commit 38c9577

Add BOLD extension so *foo* puts in bold

author Olivier Brunel
2022-12-28 10:37:45 UTC
committer Olivier Brunel
2023-07-19 12:44:21 UTC
parent dbd453cd3ef51ff02e438beb615738f01d6c4b38

Add BOLD extension so *foo* puts in bold

src/md4c.c +8 -1
src/md4c.h +1 -0

diff --git a/src/md4c.c b/src/md4c.c
index 2f12d63..54783df 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -3107,7 +3107,7 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode)
                     right_level = 2;
 
                 /* Intra-word underscore doesn't have special meaning. */
-                if(ch == _T('_')  &&  left_level == 2  &&  right_level == 2) {
+                if(ISANYOF_(ch, _T("*_"))  &&  left_level == 2  &&  right_level == 2) {
                     left_level = 0;
                     right_level = 0;
                 }
@@ -4282,6 +4282,13 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
                     MD_FALLTHROUGH();
 
                 case '*':       /* Emphasis, strong emphasis. */
+                    if(ctx->parser.flags & MD_FLAG_BOLD) {
+                        if(mark->flags & MD_MARK_OPENER)
+                            MD_ENTER_SPAN(MD_SPAN_STRONG, NULL);
+                        else
+                            MD_LEAVE_SPAN(MD_SPAN_STRONG, NULL);
+                        break;
+                    }
                     if(mark->flags & MD_MARK_OPENER) {
                         if((mark->end - off) % 2) {
                             MD_ENTER_SPAN(MD_SPAN_EM, NULL);
diff --git a/src/md4c.h b/src/md4c.h
index 38619eb..80176d4 100644
--- a/src/md4c.h
+++ b/src/md4c.h
@@ -317,6 +317,7 @@ typedef struct MD_SPAN_WIKILINK {
 #define MD_FLAG_WIKILINKS                   0x2000  /* Enable wiki links extension. */
 #define MD_FLAG_UNDERLINE                   0x4000  /* Enable underline extension (and disables '_' for normal emphasis). */
 #define MD_FLAG_ITALIC                      0x8000  /* Enable italic (/foo/) extension. */
+#define MD_FLAG_BOLD                        0x10000 /* Enable bold extension */
 
 #define MD_FLAG_PERMISSIVEAUTOLINKS         (MD_FLAG_PERMISSIVEEMAILAUTOLINKS | MD_FLAG_PERMISSIVEURLAUTOLINKS | MD_FLAG_PERMISSIVEWWWAUTOLINKS)
 #define MD_FLAG_NOHTML                      (MD_FLAG_NOHTMLBLOCKS | MD_FLAG_NOHTMLSPANS)