ext/mmd/memoir.c in rmultimarkdown-6.2.2.1 vs ext/mmd/memoir.c in rmultimarkdown-6.4.0.1
- old
+ new
@@ -53,10 +53,11 @@
*/
#include "latex.h"
#include "memoir.h"
+#include "parser.h"
#define print(x) d_string_append(out, x)
#define print_const(x) d_string_append_c_array(out, x, sizeof(x) - 1)
#define print_char(x) d_string_append_c(out, x)
#define printf(...) d_string_append_printf(out, __VA_ARGS__)
@@ -68,10 +69,11 @@
if (t == NULL) {
return;
}
char * temp_char = NULL;
+ token * temp_token = NULL;
switch (t->type) {
case DOC_START_TOKEN:
mmd_export_token_tree_memoir(out, source, t->child, scratch);
break;
@@ -80,9 +82,36 @@
pad(out, 2, scratch);
temp_char = get_fence_language_specifier(t->child->child, source);
if (temp_char) {
+ if (strncmp("{=", temp_char, 2) == 0) {
+ // Raw source
+ if (raw_filter_text_matches(temp_char, FORMAT_MEMOIR)) {
+ switch (t->child->tail->type) {
+ case LINE_FENCE_BACKTICK_3:
+ case LINE_FENCE_BACKTICK_4:
+ case LINE_FENCE_BACKTICK_5:
+ temp_token = t->child->tail;
+ break;
+
+ default:
+ temp_token = NULL;
+ }
+
+ if (temp_token) {
+ d_string_append_c_array(out, &source[t->child->next->start], temp_token->start - t->child->next->start);
+ scratch->padded = 1;
+ } else {
+ d_string_append_c_array(out, &source[t->child->start + t->child->len], t->start + t->len - t->child->next->start);
+ scratch->padded = 0;
+ }
+ }
+
+ free(temp_char);
+ break;
+ }
+
printf("\\begin{adjustwidth}{2.5em}{2.5em}\n\\begin{lstlisting}[language=%s]\n", temp_char);
} else {
print_const("\\begin{adjustwidth}{2.5em}{2.5em}\n\\begin{verbatim}\n");
}