Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion html.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,21 +739,28 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
case HTML:
g_string_append_printf(out, "%s", n->str);
break;
case ADMONITION:
case DEFLIST:
pad(out,2, scratch);
scratch->padded = 1;
g_string_append_printf(out, "<dl>\n");
if (n->key == ADMONITION) {
g_string_append_printf(out, "<dl class=\"admonition %s\">\n", n->str);
} else {
g_string_append_printf(out, "<dl>\n");
}
print_html_node_tree(out, n->children, scratch);
g_string_append_printf(out, "</dl>");
scratch->padded = 0;
break;
case ADMONITIONTITLE:
case TERM:
pad(out,1, scratch);
g_string_append_printf(out, "<dt>");
print_html_node_tree(out, n->children, scratch);
g_string_append_printf(out, "</dt>\n");
scratch->padded = 1;
break;
case ADMONITIONCONTENT:
case DEFINITION:
pad(out,1, scratch);
scratch->padded = 1;
Expand Down
3 changes: 3 additions & 0 deletions latex.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
scratch->padded = 0;
}
break;
case ADMONITION:
case DEFLIST:
pad(out,2, scratch);
g_string_append_printf(out, "\\begin{description}");
Expand All @@ -813,13 +814,15 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
g_string_append_printf(out, "\\end{description}");
scratch->padded = 0;
break;
case ADMONITIONTITLE:
case TERM:
pad(out,2, scratch);
g_string_append_printf(out, "\\item[");
print_latex_node_tree(out, n->children, scratch);
g_string_append_printf(out, "]");
scratch->padded = 0;
break;
case ADMONITIONCONTENT:
case DEFINITION:
pad(out, 2, scratch);
scratch->padded = 2;
Expand Down
3 changes: 3 additions & 0 deletions libMultiMarkdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ enum keys {
ABBRSTART,
ABBRSTOP,
TOC,
ADMONITION,
ADMONITIONTITLE,
ADMONITIONCONTENT,
KEY_COUNTER /* This *MUST* be the last item in the list */
};

Expand Down
15 changes: 12 additions & 3 deletions lyx.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ GString *used_abbreviations;
"ABBR",
"ABBRSTART",
"ABBRSTOP",
"ADMONITION",
"ADMONITIONTITLE",
"ADMONITIONCONTENT",
"KEY_COUNTER"
};

Expand Down Expand Up @@ -848,8 +851,9 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
break;
case BULLETLIST:
case ORDEREDLIST:
case ADMONITION:
case DEFLIST:
if (n->key == DEFLIST){
if (n->key == DEFLIST || n->key == ADMONITION){
scratch->lyx_definition_hit = TRUE;
scratch->lyx_definition_open = FALSE;
}
Expand Down Expand Up @@ -883,8 +887,11 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
print_lyx_node(out,temp_node,scratch,no_newline);
/* now process any other content, including additional lists */
temp_node = temp_node-> next;
while ((temp_node != NULL) && (temp_node->key != BULLETLIST)
&& (temp_node->key != ORDEREDLIST) && (temp_node->key != DEFLIST)){
while ((temp_node != NULL)
&& (temp_node->key != BULLETLIST)
&& (temp_node->key != ORDEREDLIST)
&& (temp_node->key != DEFLIST)
&& (temp_node->key != ADMONITION)){
i++;
if (i == 1){
g_string_append(out,"\n\\begin_deeper\n");
Expand Down Expand Up @@ -1504,6 +1511,7 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
g_string_append(out,"\n\n\\end_layout\n\\end_inset\n");
}
break;
case ADMONITIONTITLE:
case TERM:
scratch->lyx_definition_open = FALSE; /* and it is closed */
old_type = scratch->lyx_para_type;
Expand Down Expand Up @@ -1532,6 +1540,7 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
g_string_free(temp_str,TRUE);
scratch->lyx_para_type = old_type;
break;
case ADMONITIONCONTENT:
case DEFINITION:
if (!scratch -> lyx_definition_hit){
g_string_append(out,"\n\\series default\n"); /* close bolding */
Expand Down
1 change: 1 addition & 0 deletions lyxbeamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void print_lyxbeamer_node(GString *out, node *n, scratch_pad *scratch, bool no_n
case BULLETLIST:
case ORDEREDLIST:
scratch -> lyx_beamerbullet = TRUE;
case ADMONITION:
case DEFLIST:
old_type = scratch->lyx_para_type;
scratch->lyx_para_type = n->key;
Expand Down
2 changes: 2 additions & 0 deletions memoir.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void print_memoir_node(GString *out, node *n, scratch_pad *scratch) {
case HEADINGSECTION:
print_memoir_node_tree(out, n->children, scratch);
break;
case ADMONITION:
case DEFLIST:
pad(out, 2, scratch);
g_string_append_printf(out, "\\begin{description}");
Expand All @@ -67,6 +68,7 @@ void print_memoir_node(GString *out, node *n, scratch_pad *scratch) {
g_string_append_printf(out, "\\end{description}");
scratch->padded = 0;
break;
case ADMONITIONCONTENT:
case DEFINITION:
pad(out, 2, scratch);
scratch->padded = 2;
Expand Down
3 changes: 3 additions & 0 deletions odf.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,16 +710,19 @@ void print_odf_node(GString *out, node *n, scratch_pad *scratch) {
g_string_append_printf(out, "%s", &n->str[4]);
}
break;
case ADMONITION:
case DEFLIST:
print_odf_node_tree(out, n->children, scratch);
break;
case ADMONITIONTITLE:
case TERM:
pad(out,1, scratch);
g_string_append_printf(out, "<text:p><text:span text:style-name=\"MMD-Bold\">");
print_odf_node_tree(out, n->children, scratch);
g_string_append_printf(out, "</text:span></text:p>\n");
scratch->padded = 1;
break;
case ADMONITIONCONTENT:
case DEFINITION:
old_type = scratch->odf_para_type;
scratch->odf_para_type = DEFINITION;
Expand Down
34 changes: 34 additions & 0 deletions parser.leg
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Block = BlankLine*
| &{ !ext(EXT_COMPATIBILITY) } Fenced
| Verbatim
| &{ !ext(EXT_COMPATIBILITY) } DefinitionList
| &{ !ext(EXT_COMPATIBILITY) } Admonition
| &{ !ext(EXT_COMPATIBILITY) } Glossary
| Note
| LinkReference
Expand All @@ -139,6 +140,7 @@ HeadingSectionBlock = BlankLine* !Heading
| &{ !ext(EXT_COMPATIBILITY) } Fenced
| Verbatim
| &{ !ext(EXT_COMPATIBILITY) } DefinitionList
| &{ !ext(EXT_COMPATIBILITY) } Admonition
| &{ !ext(EXT_COMPATIBILITY) } Glossary
| Note
| LinkReference
Expand Down Expand Up @@ -862,6 +864,38 @@ Definition = (a:StartList b:StartList
$$ = list(DEFINITION,raw);
}

Admonition = AdmonitionMark Sp a:AdmonitionName Sp b:AdmonitionTitle Newline c:AdmonitionContent {
a->children = b;
b->next = c;
$$ = a;
}

AdmonitionMark = '!!!'

AdmonitionEnd = Sp AdmonitionMark?

AdmonitionName = < AlphanumericAscii (AlphanumericAscii | '-' | '_')* > { $$ = str(yytext); $$->key = ADMONITION; }

AdmonitionTitle = a:StartList ( (QuotedValue AdmonitionEnd { a = cons(str(yytext), a); }) | (AdmonitionEnd {
a = cons(str(yytext), a);
for (int idx = 0; a->str[idx]; idx++) {
if (idx == 0) a->str[idx] = toupper(a->str[idx]);
if (a->str[idx] == '_') a->str[idx] = ' ';
}
}) ) { $$ = mk_list(ADMONITIONTITLE, a); }

AdmonitionContent = (a:StartList b:StartList
(BlankLine { b = cons(mk_str("\n"),b); } )?
(IndentedLine { a = cons($$, a); })+
( BlankLine { a = cons(mk_str("\n"), a); }
(IndentedLine { a = cons($$, a); })+ { a = cons(mk_str("\n"), a); }
)* ) {
if (b != NULL) { a = cons(b,a);}
node *raw = mk_str_from_list(a, false);
raw->key = RAW;
$$ = list(ADMONITIONCONTENT, raw);
}

Bullet = !HorizontalRule NonindentSpace ('+' | '*' | '-') Spacechar+

BulletNoSpace = !HorizontalRule NonindentSpace ('+' | '*' | '-')
Expand Down