Skip to content
Browse files

Merge branch 'master' into mac-installer

  • Loading branch information...
2 parents 7a5543d + c7b97dd commit 0b7d651f04e54f45375cf9a11252ed16255cad71 @fletcher fletcher committed Jul 31, 2011
Showing with 66 additions and 31 deletions.
  1. +5 −1 Makefile
  2. +1 −1 MarkdownTest
  3. +1 −1 documentation
  4. +8 −3 markdown.c
  5. +1 −0 markdown_lib.h
  6. +18 −5 markdown_output.c
  7. +32 −20 markdown_parser.leg
View
6 Makefile
@@ -1,6 +1,6 @@
ALL : multimarkdown
-VERSION=3.0.2
+VERSION=3.1b1
PROGRAM=multimarkdown
@@ -51,6 +51,10 @@ mmdtest: $(PROGRAM)
cd MarkdownTest; \
./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=MultiMarkdownTests
+compattest: $(PROGRAM)
+ cd MarkdownTest; \
+ ./MarkdownTest.pl --Script=../$(PROGRAM) --Tidy --testdir=CompatibilityTests --Flags="-c"
+
latextest: $(PROGRAM)
cd MarkdownTest; \
./MarkdownTest.pl --Script=../$(PROGRAM) --testdir=MultiMarkdownTests --Flags="-t latex" --ext=".tex"; \
2 MarkdownTest
@@ -1 +1 @@
-Subproject commit 4360353ed2d7d74d92727b015adfeb5c56dde6f0
+Subproject commit 70b0f47e3db9f847ba96477f91e9a849b064aef0
2 documentation
@@ -1 +1 @@
-Subproject commit e038ec64c79155d42a13c868576ecf9d4b635a78
+Subproject commit 49395ade14ae95089320d6a3520cd05b3d4ddfd3
View
11 markdown.c
@@ -35,7 +35,7 @@ static int extensions;
***********************************************************************/
-#define VERSION "3.0.2"
+#define VERSION "3.1b1"
#define COPYRIGHT "portions Copyright (c) 2010-2011 Fletcher T. Penney.\n" \
"original Copyright (c) 2008-2009 John MacFarlane. License GPLv2+ or MIT.\n" \
"This is free software: you are free to change and redistribute it.\n" \
@@ -82,6 +82,7 @@ int main(int argc, char * argv[]) {
static gboolean opt_compatibility = FALSE;
static gboolean opt_batchmode = FALSE;
static gchar *opt_extract_meta = FALSE;
+ static gboolean opt_no_labels = FALSE;
static GOptionEntry entries[] =
{
@@ -105,6 +106,7 @@ int main(int argc, char * argv[]) {
{ "notes", 0, 0, G_OPTION_ARG_NONE, &opt_notes, "use notes extension (on by default)", NULL },
{ "nonotes", 0, 0, G_OPTION_ARG_NONE, &opt_no_notes, "do not use notes extension", NULL },
{ "process-html", 0, 0, G_OPTION_ARG_NONE, &opt_process_html, "process MultiMarkdown inside of raw HTML", NULL },
+ { "nolabels", 0, 0, G_OPTION_ARG_NONE, &opt_no_labels, "do not look for possible cross-references - improves speed", NULL},
{ NULL }
};
@@ -149,13 +151,16 @@ int main(int argc, char * argv[]) {
extensions = extensions | EXT_FILTER_HTML;
if (opt_filter_styles)
extensions = extensions | EXT_FILTER_STYLES;
+ if (opt_no_labels)
+ extensions = extensions | EXT_NO_LABELS;
/* Compatibility mode turns off extensions and most
MultiMarkdown-specific features */
- if (opt_compatibility)
+ if (opt_compatibility) {
extensions = 0x000000;
- if (opt_compatibility)
extensions = extensions | EXT_COMPATIBILITY;
+ extensions = extensions | EXT_NO_LABELS;
+ }
if (opt_to == NULL)
output_format = HTML_FORMAT;
View
1 markdown_lib.h
@@ -9,6 +9,7 @@ enum markdown_extensions {
EXT_FILTER_STYLES = 0x08,
EXT_COMPATIBILITY = 0x10,
EXT_PROCESS_HTML = 0x20,
+ EXT_NO_LABELS = 0x40,
};
enum markdown_formats {
View
23 markdown_output.c
@@ -38,6 +38,8 @@ static bool html_footer = FALSE;
static int odf_type = 0;
static bool in_list = FALSE;
static bool no_latex_footnote = FALSE;
+static bool am_printing_html_footnote = FALSE;
+static int footnote_counter_to_print = 0;
static void print_html_string(GString *out, char *str, bool obfuscate);
static void print_html_element_list(GString *out, element *list, bool obfuscate);
@@ -185,7 +187,7 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) {
int lev;
char *label;
element *attribute;
- element *locator;
+ element *locator = NULL;
char *height;
char *width;
switch (elt->key) {
@@ -258,7 +260,9 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) {
(strcmp(elt->contents.link->identifier, "") == 0) ) {
g_string_append_printf(out, "\"");
} else {
- g_string_append_printf(out, "\" id=\"%s\"",elt->contents.link->identifier);
+ if (!(extension(EXT_COMPATIBILITY))) {
+ g_string_append_printf(out, "\" id=\"%s\"",elt->contents.link->identifier);
+ }
}
if (strlen(elt->contents.link->title) > 0) {
g_string_append_printf(out, " title=\"");
@@ -344,6 +348,12 @@ static void print_html_element(GString *out, element *elt, bool obfuscate) {
pad(out, 2);
g_string_append_printf(out, "<p>");
print_html_element_list(out, elt->children, obfuscate);
+ if (am_printing_html_footnote && ( elt->next == NULL)) {
+ g_string_append_printf(out, " <a href=\"#fnref:%d\" title=\"return to article\" class=\"reversefootnote\">&#160;&#8617;</a>", footnote_counter_to_print);
+ /* Only print once. For now, it's the first paragraph, until
+ I can figure out to make it the last paragraph */
+ am_printing_html_footnote = FALSE;
+ }
g_string_append_printf(out, "</p>");
padded = 0;
break;
@@ -719,8 +729,11 @@ static void print_html_endnotes(GString *out) {
} else {
g_string_append_printf(out, "<li id=\"fn:%d\">\n", counter);
padded = 2;
+ am_printing_html_footnote = TRUE;
+ footnote_counter_to_print = counter;
print_html_element_list(out, note_elt, false);
- g_string_append_printf(out, " <a href=\"#fnref:%d\" title=\"return to article\" class=\"reversefootnote\">&#160;&#8617;</a>", counter);
+ am_printing_html_footnote = FALSE;
+ footnote_counter_to_print = 0;
pad(out, 1);
g_string_append_printf(out, "</li>");
}
@@ -1202,7 +1215,7 @@ static void print_latex_element(GString *out, element *elt) {
}
}
}
- if (elt->children->contents.str == NULL) {
+ if ((elt->children != NULL) && (elt->children->contents.str == NULL)) {
elt->children->contents.str = strdup(elt->contents.str);
add_endnote(elt->children);
}
@@ -1705,7 +1718,7 @@ void print_odf_element(GString *out, element *elt) {
char *label;
char *height;
char *width;
- element *locator;
+ element *locator = NULL;
int old_type = 0;
switch (elt->key) {
case SPACE:
View
52 markdown_parser.leg
@@ -60,19 +60,21 @@ MetaDataKeyValue = a:MetaDataKey
$$->children = b;
}
-MetaDataKey = < AlphanumericAscii ( Sp ( AlphanumericAscii | '_' | ' ' | '-')+)* >
+MetaDataKey = < !([A-Za-z]+ "://") AlphanumericAscii ( Sp ( AlphanumericAscii | '_' | ' ' | '-')+)* >
{
char *label = label_from_string(yytext,0);
$$ = mk_str(label);
free(label);
$$->key = METAKEY;
}
+SingleLineMetaKeyValue = MetaDataKey Sp ':' Sp (!Newline .)*
+
MetaDataValue = a:StartList
((< (!Newline .)* > { a = cons(mk_str(yytext), a); })
- ((Newline &(!BlankLine !MetaDataKeyValue Sp RawLine))
+ ((Newline &(!BlankLine !SingleLineMetaKeyValue Sp RawLine))
{ a = cons(mk_str("\n"), a);} | Newline)
- (!BlankLine !MetaDataKeyValue Sp RawLine
+ (!BlankLine !SingleLineMetaKeyValue Sp RawLine
{ a = cons(mk_str(yytext), a);} )* )
{ $$ = mk_str_from_list(a,false);
trim_trailing_whitespace($$->contents.str);
@@ -82,8 +84,8 @@ MetaDataValue = a:StartList
Block = BlankLine*
( BlockQuote
| Verbatim
- | DefinitionList
- | Glossary
+ | &{ !extension(EXT_COMPATIBILITY) } DefinitionList
+ | &{ !extension(EXT_COMPATIBILITY) } Glossary
| Note
| Reference
| HorizontalRule
@@ -92,7 +94,7 @@ Block = BlankLine*
| BulletList
| HtmlBlock
| StyleBlock
- | Table
+ | &{ !extension(EXT_COMPATIBILITY) } Table
| &{ !extension(EXT_COMPATIBILITY) } ImageBlock
| !(Sp? HtmlBlockOpenDiv) Para
| Plain )
@@ -102,16 +104,16 @@ HeadingSectionBlock =
!Heading
( BlockQuote
| Verbatim
- | DefinitionList
- | Glossary
+ | &{ !extension(EXT_COMPATIBILITY) } DefinitionList
+ | &{ !extension(EXT_COMPATIBILITY) } Glossary
| Note
| Reference
| HorizontalRule
| OrderedList
| BulletList
| HtmlBlock
| StyleBlock
- | Table
+ | &{ !extension(EXT_COMPATIBILITY) } Table
| &{ !extension(EXT_COMPATIBILITY) } ImageBlock
| !(Sp? HtmlBlockOpenDiv) Para
| Plain )
@@ -460,17 +462,17 @@ Inlines = a:StartList ( !Endline Inline { a = cons($$, a); }
{ $$ = mk_list(LIST, a); }
Inline = Str
- | MathSpan
+ | &{ !extension(EXT_COMPATIBILITY) } MathSpan
| Endline
| UlOrStarLine
| Space
| Strong
| Emph
- | CitationReference
+ | &{ !extension(EXT_COMPATIBILITY) } CitationReference
| Image
| Link
| NoteReference
- # | InlineNote # Not used in MultiMarkdown
+ # | InlineNote # Not used in Markdown/MultiMarkdown
| Code
| MarkdownHtmlTagOpen
| RawHtml
@@ -663,7 +665,10 @@ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_]+ '@' ( !Newline !'>' . )+ >
}
Reference = a:StartList NonindentSpace !"[]" l:Label ':' Spnl s:RefSrc
- t:RefTitle (Attributes { a = cons($$,a);})? BlankLine+
+ t:RefTitle
+ ( &{ !extension(EXT_COMPATIBILITY) }
+ (Attributes { a = cons($$,a);})? )?
+ BlankLine+
{
char *label;
GString *text = g_string_new("");
@@ -728,11 +733,14 @@ RefTitle = ( RefTitleSingle | RefTitleDouble | RefTitleParens | EmptyTitle )
EmptyTitle = < "" >
-RefTitleSingle = Spnl '\'' < ( !( '\'' Sp Newline | Newline | '\'' Sp AlphanumericAscii+ '=' ) . )* > '\''
+RefTitleSingle = Spnl '\'' < ( !( '\'' Sp Newline | Newline |
+ &{ !extension(EXT_COMPATIBILITY) } '\'' Sp AlphanumericAscii+ '=' ) . )* > '\''
-RefTitleDouble = Spnl '"' < ( !('"' Sp Newline | Newline | '"' Sp AlphanumericAscii+ '=' ) . )* > '"'
+RefTitleDouble = Spnl '"' < ( !('"' Sp Newline | Newline |
+ &{ !extension(EXT_COMPATIBILITY) } '"' Sp AlphanumericAscii+ '=' ) . )* > '"'
-RefTitleParens = Spnl '(' < ( !(')' Sp Newline | Newline | ')' Sp AlphanumericAscii+ '=' ) . )* > ')'
+RefTitleParens = Spnl '(' < ( !(')' Sp Newline | Newline |
+ &{ !extension(EXT_COMPATIBILITY) } ')' Sp AlphanumericAscii+ '=' ) . )* > ')'
References = a:StartList
( b:Reference { a = cons(b, a); } | SkipBlock )*
@@ -773,7 +781,7 @@ Nonspacechar = !Spacechar !Newline .
Newline = '\n' | '\r' '\n'?
Sp = Spacechar*
Spnl = Sp (Newline Sp)?
-SpecialChar = '*' | '_' | '`' | '&' | '[' | ']' | '(' | ')' | '<' | '!' | '#' | '\\' | ExtendedSpecialChar
+SpecialChar = '*' | '_' | '`' | '&' | '[' | ']' | '(' | ')' | '<' | '!' | '#' | '\\' | '\'' | '"' | ExtendedSpecialChar
NormalChar = !( SpecialChar | Spacechar | Newline ) .
NonAlphanumeric = [\000-\057\072-\100\133-\140\173-\177]
Alphanumeric = [0-9A-Za-z] | '\200' | '\201' | '\202' | '\203' | '\204' | '\205' | '\206' | '\207' | '\210' | '\211' | '\212' | '\213' | '\214' | '\215' | '\216' | '\217' | '\220' | '\221' | '\222' | '\223' | '\224' | '\225' | '\226' | '\227' | '\230' | '\231' | '\232' | '\233' | '\234' | '\235' | '\236' | '\237' | '\240' | '\241' | '\242' | '\243' | '\244' | '\245' | '\246' | '\247' | '\250' | '\251' | '\252' | '\253' | '\254' | '\255' | '\256' | '\257' | '\260' | '\261' | '\262' | '\263' | '\264' | '\265' | '\266' | '\267' | '\270' | '\271' | '\272' | '\273' | '\274' | '\275' | '\276' | '\277' | '\300' | '\301' | '\302' | '\303' | '\304' | '\305' | '\306' | '\307' | '\310' | '\311' | '\312' | '\313' | '\314' | '\315' | '\316' | '\317' | '\320' | '\321' | '\322' | '\323' | '\324' | '\325' | '\326' | '\327' | '\330' | '\331' | '\332' | '\333' | '\334' | '\335' | '\336' | '\337' | '\340' | '\341' | '\342' | '\343' | '\344' | '\345' | '\346' | '\347' | '\350' | '\351' | '\352' | '\353' | '\354' | '\355' | '\356' | '\357' | '\360' | '\361' | '\362' | '\363' | '\364' | '\365' | '\366' | '\367' | '\370' | '\371' | '\372' | '\373' | '\374' | '\375' | '\376' | '\377'
@@ -985,7 +993,8 @@ RawCitationReference = "[#" < ( !Newline !']' . )+ > ']'
{ $$ = mk_str(yytext); }
-AutoLabels = a:StartList ( b:Heading
+AutoLabels = ( &{ !extension(EXT_COMPATIBILITY) && !extension(EXT_NO_LABELS)}
+ a:StartList ( b:Heading
{
GString *label = g_string_new("");
char *lab;
@@ -1026,9 +1035,10 @@ AutoLabels = a:StartList ( b:Heading
g_string_free(label,true);
free_element_list(c);}
| SkipBlock )*
- { labels = a; }
+ { labels = a; })
-DefinitionList = a:StartList (
+DefinitionList = a:StartList &(TermLine+ ':')
+ (
(Term { a = cons($$, a); } )+
(Definition { a = cons($$, a);})+
BlankLine*
@@ -1037,6 +1047,8 @@ DefinitionList = a:StartList (
$$->key = DEFLIST;
}
+TermLine = !':' !BlankLine (!Newline .)* Newline
+
Term = a:StartList !BlankLine !':'
(!Newline !Endline Inline {a = cons($$, a);} )+ Newline
{

0 comments on commit 0b7d651

Please sign in to comment.
Something went wrong with that request. Please try again.