summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commonmark.c2
-rw-r--r--src/latex.c222
-rw-r--r--src/man.c1
-rw-r--r--src/render.c4
4 files changed, 115 insertions, 114 deletions
diff --git a/src/commonmark.c b/src/commonmark.c
index 5d098e7..dbb1910 100644
--- a/src/commonmark.c
+++ b/src/commonmark.c
@@ -56,8 +56,6 @@ static inline void outc(cmark_renderer *renderer,
} else {
cmark_render_code_point(renderer, c);
}
- renderer->begin_line = (c == 10);
-
}
static int
diff --git a/src/latex.c b/src/latex.c
index 592c40c..34dffc7 100644
--- a/src/latex.c
+++ b/src/latex.c
@@ -25,124 +25,124 @@ static inline void outc(cmark_renderer *renderer,
{
if (escape == LITERAL) {
cmark_render_code_point(renderer, c);
- } else {
- switch(c) {
- case 123: // '{'
- case 125: // '}'
- case 35: // '#'
- case 37: // '%'
- case 38: // '&'
+ return;
+ }
+
+ switch(c) {
+ case 123: // '{'
+ case 125: // '}'
+ case 35: // '#'
+ case 37: // '%'
+ case 38: // '&'
+ cmark_render_ascii(renderer, "\\");
+ cmark_render_code_point(renderer, c);
+ break;
+ case 36: // '$'
+ case 95: // '_'
+ if (escape == NORMAL) {
cmark_render_ascii(renderer, "\\");
+ }
+ cmark_render_code_point(renderer, c);
+ break;
+ case 45 : // '-'
+ if (nextc == 45) { // prevent ligature
+ cmark_render_ascii(renderer, "\\-");
+ } else {
+ cmark_render_ascii(renderer, "-");
+ }
+ break;
+ case 126: // '~'
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "\\textasciitilde{}");
+ } else {
cmark_render_code_point(renderer, c);
- break;
- case 36: // '$'
- case 95: // '_'
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "\\");
- }
+ }
+ break;
+ case 94: // '^'
+ cmark_render_ascii(renderer, "\\^{}");
+ break;
+ case 92: // '\\'
+ if (escape == URL) {
+ // / acts as path sep even on windows:
+ cmark_render_ascii(renderer, "/");
+ } else {
+ cmark_render_ascii(renderer, "\\textbackslash{}");
+ }
+ break;
+ case 124: // '|'
+ cmark_render_ascii(renderer, "\\textbar{}");
+ break;
+ case 60: // '<'
+ cmark_render_ascii(renderer, "\\textless{}");
+ break;
+ case 62: // '>'
+ cmark_render_ascii(renderer, "\\textgreater{}");
+ break;
+ case 91: // '['
+ case 93: // ']'
+ cmark_render_ascii(renderer, "{");
+ cmark_render_code_point(renderer, c);
+ cmark_render_ascii(renderer, "}");
+ break;
+ case 34: // '"'
+ cmark_render_ascii(renderer, "\\textquotedbl{}");
+ // requires \usepackage[T1]{fontenc}
+ break;
+ case 39: // '\''
+ cmark_render_ascii(renderer, "\\textquotesingle{}");
+ // requires \usepackage{textcomp}
+ break;
+ case 160: // nbsp
+ cmark_render_ascii(renderer, "~");
+ break;
+ case 8230: // hellip
+ cmark_render_ascii(renderer, "\\ldots{}");
+ break;
+ case 8216: // lsquo
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "`");
+ } else {
cmark_render_code_point(renderer, c);
- break;
- case 45 : // '-'
- if (nextc == 45) { // prevent ligature
- cmark_render_ascii(renderer, "\\-");
- } else {
- cmark_render_ascii(renderer, "-");
- }
- break;
- case 126: // '~'
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "\\textasciitilde{}");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- case 94: // '^'
- cmark_render_ascii(renderer, "\\^{}");
- break;
- case 92: // '\\'
- if (escape == URL) {
- // / acts as path sep even on windows:
- cmark_render_ascii(renderer, "/");
- } else {
- cmark_render_ascii(renderer, "\\textbackslash{}");
- }
- break;
- case 124: // '|'
- cmark_render_ascii(renderer, "\\textbar{}");
- break;
- case 60: // '<'
- cmark_render_ascii(renderer, "\\textless{}");
- break;
- case 62: // '>'
- cmark_render_ascii(renderer, "\\textgreater{}");
- break;
- case 91: // '['
- case 93: // ']'
- cmark_render_ascii(renderer, "{");
+ }
+ break;
+ case 8217: // rsquo
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "\'");
+ } else {
cmark_render_code_point(renderer, c);
- cmark_render_ascii(renderer, "}");
- break;
- case 34: // '"'
- cmark_render_ascii(renderer, "\\textquotedbl{}");
- // requires \usepackage[T1]{fontenc}
- break;
- case 39: // '\''
- cmark_render_ascii(renderer, "\\textquotesingle{}");
- // requires \usepackage{textcomp}
- break;
- case 160: // nbsp
- cmark_render_ascii(renderer, "~");
- break;
- case 8230: // hellip
- cmark_render_ascii(renderer, "\\ldots{}");
- break;
- case 8216: // lsquo
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "`");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- case 8217: // rsquo
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "\'");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- case 8220: // ldquo
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "``");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- case 8221: // rdquo
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "''");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- case 8212: // emdash
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "---");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- case 8211: // endash
- if (escape == NORMAL) {
- cmark_render_ascii(renderer, "--");
- } else {
- cmark_render_code_point(renderer, c);
- }
- break;
- default:
+ }
+ break;
+ case 8220: // ldquo
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "``");
+ } else {
cmark_render_code_point(renderer, c);
}
+ break;
+ case 8221: // rdquo
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "''");
+ } else {
+ cmark_render_code_point(renderer, c);
+ }
+ break;
+ case 8212: // emdash
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "---");
+ } else {
+ cmark_render_code_point(renderer, c);
+ }
+ break;
+ case 8211: // endash
+ if (escape == NORMAL) {
+ cmark_render_ascii(renderer, "--");
+ } else {
+ cmark_render_code_point(renderer, c);
+ }
+ break;
+ default:
+ cmark_render_code_point(renderer, c);
}
- renderer->begin_line = (c == 10);
}
typedef enum {
diff --git a/src/man.c b/src/man.c
index b2e0ce2..4a49441 100644
--- a/src/man.c
+++ b/src/man.c
@@ -71,7 +71,6 @@ void S_outc(cmark_renderer *renderer,
default:
cmark_render_code_point(renderer, c);
}
- renderer->begin_line = (c == 10);
}
static int
diff --git a/src/render.c b/src/render.c
index 9fea832..ab53558 100644
--- a/src/render.c
+++ b/src/render.c
@@ -86,8 +86,12 @@ void S_out(cmark_renderer *renderer,
renderer->column = 0;
renderer->begin_line = true;
renderer->last_breakable = 0;
+ } else if (escape == LITERAL) {
+ cmark_render_code_point(renderer, c);
+ renderer->begin_line = false;
} else {
(renderer->outc)(renderer, escape, c, nextc);
+ renderer->begin_line = false;
}
// If adding the character went beyond width, look for an