Welcome to little lamb

Code » md4c » commit 6831fbe

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:29:32 UTC
parent 6b58ae194c3cd6a9b6d7f81597d5eea559961156

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 43d7655..ecc3a77 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -3101,7 +3101,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;
                 }
@@ -4258,6 +4258,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 95f78f9..8bf4adc 100644
--- a/src/md4c.h
+++ b/src/md4c.h
@@ -316,6 +316,7 @@ typedef struct MD_SPAN_WIKILINK {
 #define MD_FLAG_LATEXMATHSPANS              0x1000  /* Enable $ and $$ containing LaTeX equations. */
 #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_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)