Skip to content

Commit

Permalink
Add CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE. Closes #71.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Jan 25, 2018
1 parent 2ed8b89 commit c159d7b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion extensions/strikethrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static cmark_node *match(cmark_syntax_extension *self, cmark_parser *parser,
res->start_line = res->end_line = cmark_inline_parser_get_line(inline_parser);
res->start_column = cmark_inline_parser_get_column(inline_parser) - delims;

if (left_flanking || right_flanking) {
if ((left_flanking || right_flanking) &&
(!(parser->options & CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE) || delims == 2)) {
cmark_inline_parser_push_delimiter(inline_parser, character, left_flanking,
right_flanking, res);
}
Expand Down
15 changes: 14 additions & 1 deletion man/man3/cmark-gfm.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH cmark-gfm 3 "November 09, 2017" "LOCAL" "Library Functions Manual"
.TH cmark-gfm 3 "January 25, 2018" "LOCAL" "Library Functions Manual"
.SH
NAME
.PP
Expand Down Expand Up @@ -957,6 +957,19 @@ Be liberal in interpreting inline HTML tags.
.PP
Parse footnotes.

.PP
.nf
\fC
.RS 0n
#define CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE (1 << 14)
.RE
\f[]
.fi

.PP
Only parse strikethroughs if surrounded by exactly 2 tildes. Gives some
compatibility with redcarpet.

.SS
Version information

Expand Down
5 changes: 5 additions & 0 deletions src/cmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@ char *cmark_render_latex_with_mem(cmark_node *root, int options, int width, cmar
*/
#define CMARK_OPT_FOOTNOTES (1 << 13)

/** Only parse strikethroughs if surrounded by exactly 2 tildes.
* Gives some compatibility with redcarpet.
*/
#define CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE (1 << 14)

/**
* ## Version information
*/
Expand Down
4 changes: 4 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void print_usage() {
printf(" --footnotes Parse footnotes\n");
printf(" --extension, -e EXTENSION_NAME Specify an extension name to use\n");
printf(" --list-extensions List available extensions and quit\n");
printf(" --strikethrough-double-tilde Only parse strikethrough (if enabled)\n");
printf(" with two tildes\n");
printf(" --help, -h Print usage information\n");
printf(" --version Print version\n");
}
Expand Down Expand Up @@ -129,6 +131,8 @@ int main(int argc, char *argv[]) {
} else if (strcmp(argv[i], "--list-extensions") == 0) {
print_extensions();
goto success;
} else if (strcmp(argv[i], "--strikethrough-double-tilde") == 0) {
options |= CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE;
} else if (strcmp(argv[i], "--sourcepos") == 0) {
options |= CMARK_OPT_SOURCEPOS;
} else if (strcmp(argv[i], "--hardbreaks") == 0) {
Expand Down

0 comments on commit c159d7b

Please sign in to comment.