Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LaTeX passthru mode #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion latex.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
print_latex_node_tree(out,n->children,scratch);
break;
case STR:
print_latex_string(out,n->str, scratch);
if (scratch->extensions & EXT_LATEX_PASSTHRU)
print_latex_unescaped_string(out, n->str, scratch);
else
print_latex_string(out,n->str, scratch);
break;
case ABBREVIATION:
/* We combine the short and full names, since stripping non-ascii characters may result
Expand Down Expand Up @@ -1121,6 +1124,16 @@ void print_latex_localized_typography(GString *out, int character, scratch_pad *
}
}

/* print_latex_unescaped_string - print string, not escaping for LaTeX */
void print_latex_unescaped_string(GString *out, char *str, scratch_pad *scratch) {
if (str == NULL)
return;
while (*str != '\0') {
g_string_append_c(out, *str);
str++;
}
}

/* print_latex_string - print string, escaping for LaTeX */
void print_latex_string(GString *out, char *str, scratch_pad *scratch) {
char *tmp;
Expand Down
1 change: 1 addition & 0 deletions latex.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
void print_latex_node_tree(GString *out, node *list, scratch_pad *scratch);
void print_latex_node(GString *out, node *n, scratch_pad *scratch);
void print_latex_localized_typography(GString *out, int character, scratch_pad *scratch);
void print_latex_unescaped_string(GString *out, char *str, scratch_pad *scratch);
void print_latex_string(GString *out, char *str, scratch_pad *scratch);
void print_latex_url(GString *out, char *str, scratch_pad *scratch);
void print_latex_endnotes(GString *out, scratch_pad *scratch);
Expand Down
1 change: 1 addition & 0 deletions libMultiMarkdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum parser_extensions {
EXT_ESCAPED_LINE_BREAKS = 1 << 17, /* Escaped line break */
EXT_NO_STRONG = 1 << 18, /* Don't allow nested <strong>'s */
EXT_NO_EMPH = 1 << 19, /* Don't allow nested <emph>'s */
EXT_LATEX_PASSTHRU = 1 << 20, /* LaTeX passthru */
EXT_FAKE = 1 << 31, /* 31 is highest number allowed */
};

Expand Down