Commit 346874e0b3c254fa49417ace98f3e0196950741c

Martin Mitas 2019-05-20T21:03:47

Add and fill MD_BLOCK_CODE_DETAIL::fence_char accordingly. For the case of indented code block, it is left zeroed. Fixes #81

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b866dbb..d93424d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,9 +5,15 @@
 ## Next Version (Work in Progress)
 
 Changes:
+
  * Update Unicode-specific code compliant to Unicode 12.1.
 
+ * Structure `MD_BLOCK_CODE_DETAIL` got new member `fenced_char`. Application
+   can use it to detect character used to form the block fences (`` ` `` or
+   `~`). In the case of indented code block, it is set to zero.
+
 Fixes:
+
  * [#77](https://github.com/mity/md4c/issues/77):
    Fix maximal count of digits for numerical character references, as requested
    by CommonMark specification 0.29.
@@ -20,6 +26,7 @@ Fixes:
 ## Version 0.3.3
 
 Changes:
+
  * Make permissive URL autolink and permissive WWW autolink extensions stricter.
 
    This brings the behavior closer to GFM and mitigates risk of false positives.
@@ -27,6 +34,7 @@ Changes:
    can be part of the link destination only if `(` and `)` are balanced.
 
 Fixes:
+
  * [#73](https://github.com/mity/md4c/issues/73):
    Some raw HTML inputs could lead to quadratic parsing times.
 
@@ -41,6 +49,7 @@ Fixes:
 ## Version 0.3.2
 
 Changes:
+
  * Changes mandated by CommonMark specification 0.29.
 
    Most importantly, the white-space trimming rules for code spans have changed.
@@ -54,6 +63,7 @@ Changes:
    for more info.
 
 Fixes:
+
  * [#68](https://github.com/mity/md4c/issues/68):
    Some specific HTML blocks were not recognized when EOF follows without any
    end-of-line character.
diff --git a/md4c/md4c.c b/md4c/md4c.c
index b4ab7e5..01e63a5 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -4461,6 +4461,8 @@ md_setup_fenced_code_detail(MD_CTX* ctx, const MD_BLOCK* block, MD_BLOCK_CODE_DE
         lang_end++;
     MD_CHECK(md_build_attribute(ctx, STR(beg), lang_end - beg, 0, &det->lang, lang_build));
 
+    det->fence_char = fence_ch;
+
 abort:
     return ret;
 }
diff --git a/md4c/md4c.h b/md4c/md4c.h
index 98118e7..dcdadad 100644
--- a/md4c/md4c.h
+++ b/md4c/md4c.h
@@ -238,6 +238,7 @@ typedef struct MD_BLOCK_H_DETAIL {
 typedef struct MD_BLOCK_CODE_DETAIL {
     MD_ATTRIBUTE info;
     MD_ATTRIBUTE lang;
+    MD_CHAR fence_char;     /* The character used for fenced code block; or zero for indented code block. */
 } MD_BLOCK_CODE_DETAIL;
 
 /* Detailed info for MD_BLOCK_TH and MD_BLOCK_TD. */