summaryrefslogtreecommitdiff
path: root/src/commonmark.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-08-25 16:08:13 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-25 16:08:13 -0700
commit880039601d2bc4baf4e17649a02480876917d0ae (patch)
treec5723a372633b480b013447a5f0f9b56f7e51b40 /src/commonmark.c
parent76478c79d3d13a21871bbed784f75fd5d9e8b1c2 (diff)
Code span spec changes.
These affect both parsing and writing commonmark.
Diffstat (limited to 'src/commonmark.c')
-rw-r--r--src/commonmark.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/commonmark.c b/src/commonmark.c
index 95a1ae5..d701bab 100644
--- a/src/commonmark.c
+++ b/src/commonmark.c
@@ -167,6 +167,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
int list_number;
cmark_delim_type list_delim;
int numticks;
+ bool extra_spaces;
int i;
bool entering = (ev_type == CMARK_EVENT_ENTER);
const char *info, *code, *title;
@@ -363,14 +364,17 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
code = cmark_node_get_literal(node);
code_len = strlen(code);
numticks = shortest_unused_backtick_sequence(code);
+ extra_spaces = code_len == 0 ||
+ code[0] == '`' || code[code_len - 1] == '`' ||
+ code[0] == ' ' || code[code_len - 1] == ' ';
for (i = 0; i < numticks; i++) {
LIT("`");
}
- if (code_len == 0 || code[0] == '`') {
+ if (extra_spaces) {
LIT(" ");
}
OUT(cmark_node_get_literal(node), allow_wrap, LITERAL);
- if (code_len == 0 || code[code_len - 1] == '`') {
+ if (extra_spaces) {
LIT(" ");
}
for (i = 0; i < numticks; i++) {