if (m) {
print_const("<dc:identifier id=\"pub-id\">urn:uuid:");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
print_const("</dc:identifier>\n");
} else {
print_const("<dc:identifier id=\"pub-id\">urn:uuid:");
if (m) {
print_const("<dc:title>");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
print_const("</dc:title>\n");
} else {
print_const("<dc:title>Untitled</dc:title>\n");
if (m) {
print_const("<dc:creator>");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
print_const("</dc:creator>\n");
}
if (m) {
print_const("<dc:language>");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
print_const("</dc:language>\n");
} else {
switch (scratch->language) {
if (m) {
print_const("<meta property=\"dcterms:modified\">");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
print_const("</meta>\n");
} else {
time_t t = time(NULL);
HASH_FIND_STR(scratch->meta_hash, "title", temp);
if (temp) {
- mmd_print_string_html(out, temp->value, false);
+ mmd_print_string_html(out, temp->value, false, false);
} else {
print_const("Untitled");
}
// Use Knuth's pseudo random generator to obfuscate email addresses predictably
long ran_num_next(void);
-void mmd_print_char_html(DString * out, char c, bool obfuscate) {
+void mmd_print_char_html(DString * out, char c, bool obfuscate, bool line_breaks) {
switch (c) {
case '"':
print_const(""");
case '\n':
case '\r':
- print_const("<br/>\n");
+ if (line_breaks) {
+ print_const("<br/>\n");
+ } else {
+ print_char(c);
+ }
break;
default:
}
-void mmd_print_string_html(DString * out, const char * str, bool obfuscate) {
+void mmd_print_string_html(DString * out, const char * str, bool obfuscate, bool line_breaks) {
if (str) {
while (*str != '\0') {
- mmd_print_char_html(out, *str, obfuscate);
+ mmd_print_char_html(out, *str, obfuscate, line_breaks);
str++;
}
}
if (link->url) {
print_const("<a href=\"");
- mmd_print_string_html(out, link->url, false);
+ mmd_print_string_html(out, link->url, false, false);
print_const("\"");
} else {
print_const("<a href=\"\"");
if (link->title && link->title[0] != '\0') {
print_const(" title=\"");
- mmd_print_string_html(out, link->title, false);
+ mmd_print_string_html(out, link->title, false, false);
print_const("\"");
}
(source[t->start + 1] == ' ')) {
print_const(" ");
} else {
- mmd_print_char_html(out, source[t->start + 1], false);
+ mmd_print_char_html(out, source[t->start + 1], false, false);
}
break;
temp_bool = true;
if (strncmp("mailto:", temp_char, 7) != 0) {
- mmd_print_string_html(out, "mailto:", true);
+ mmd_print_string_html(out, "mailto:", true, false);
}
} else {
temp_bool = false;
}
- mmd_print_string_html(out, temp_char, temp_bool);
+ mmd_print_string_html(out, temp_char, temp_bool, false);
print_const("\">");
- mmd_print_string_html(out, temp_char, temp_bool);
+ mmd_print_string_html(out, temp_char, temp_bool, false);
print_const("</a>");
} else if (scan_html(&source[t->start])) {
print_token(t);
if (temp_short2 == scratch->used_abbreviations->size) {
// This is a re-use of a previously used note
print_const("<abbr title=\"");
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, false);
print_const("\">");
if (t->child) {
print_const("</abbr>");
} else {
// This is the first time this note was used
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, false);
print_const(" (<abbr title=\"");
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, false);
print_const("\">");
if (t->child) {
}
} else {
// This is an inline definition (and therefore the first use)
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, false);
print_const(" (<abbr title=\"");
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, false);
print_const("\">");
- mmd_print_string_html(out, temp_note->label_text, false);
+ mmd_print_string_html(out, temp_note->label_text, false, false);
print_const("</abbr>)");
}
} else {
printf("<a href=\"#gn:%d\" title=\"%s\" class=\"glossary\">",
temp_short, LC("see glossary"));
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, true);
print_const("</a>");
} else {
// This is the first time this note was used
printf("<a href=\"#gn:%d\" id=\"gnref:%d\" title=\"%s\" class=\"glossary\">",
temp_short, temp_short, LC("see glossary"));
- mmd_print_string_html(out, temp_note->clean_text, false);
+ mmd_print_string_html(out, temp_note->clean_text, false, true);
print_const("</a>");
}
} else {
temp_char2 = extract_metadata(scratch, temp_char);
if (temp_char2) {
- mmd_print_string_html(out, temp_char2, false);
+ mmd_print_string_html(out, temp_char2, false, true);
} else {
mmd_export_token_tree_html(out, source, t->child, scratch);
}
if (t->next && t->next->type == TEXT_EMPTY && source[t->start + 1] == ' ') {
} else {
- mmd_print_char_html(out, source[t->start + 1], false);
+ mmd_print_char_html(out, source[t->start + 1], false, false);
}
break;
store_asset(scratch, m->value);
asset * a = extract_asset(scratch, m->value);
- mmd_print_string_html(out, "assets/", false);
- mmd_print_string_html(out, a->asset_path, false);
+ mmd_print_string_html(out, "assets/", false, false);
+ mmd_print_string_html(out, a->asset_path, false, false);
} else {
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
}
print_const("\"/>\n");
} else if (strcmp(m->key, "quoteslanguage") == 0) {
} else if (strcmp(m->key, "title") == 0) {
print_const("\t<title>");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, true);
print_const("</title>\n");
} else if (strcmp(m->key, "transcludebase") == 0) {
} else if (strcmp(m->key, "xhtmlheader") == 0) {
} else if (strcmp(m->key, "xhtmlheaderlevel") == 0) {
} else {
print_const("\t<meta name=\"");
- mmd_print_string_html(out, m->key, false);
+ mmd_print_string_html(out, m->key, false, false);
print_const("\" content=\"");
- mmd_print_string_html(out, m->value, false);
+ mmd_print_string_html(out, m->value, false, false);
print_const("\"/>\n");
}
}
content = note->content;
// Print term
- mmd_print_string_html(out, note->clean_text, false);
+ mmd_print_string_html(out, note->clean_text, false, true);
print_const(": ");
// Print contents
void mmd_start_complete_html(DString * out, const char * source, scratch_pad * scratch);
void mmd_end_complete_html(DString * out, const char * source, scratch_pad * scratch);
-void mmd_print_string_html(DString * out, const char * str, bool obfuscate);
+void mmd_print_string_html(DString * out, const char * str, bool obfuscate, bool line_breaks);
#endif
}
-void mmd_print_char_opendocument(DString * out, char c) {
+void mmd_print_char_opendocument(DString * out, char c, bool line_breaks) {
switch (c) {
case '"':
print_const(""");
case '\n':
case '\r':
- print_const("<text:line-break/>\n");
+ if (line_breaks) {
+ print_const("<text:line-break/>\n");
+ } else {
+ print_char(c);
+ }
break;
case '\t':
}
-void mmd_print_string_opendocument(DString * out, const char * str) {
+void mmd_print_string_opendocument(DString * out, const char * str, bool line_breaks) {
if (str == NULL) {
return;
}
while (*str != '\0') {
- mmd_print_char_opendocument(out, *str);
+ mmd_print_char_opendocument(out, *str, line_breaks);
str++;
}
}
if (t->next && t->next->type == TEXT_EMPTY && source[t->start + 1] == ' ') {
} else {
- mmd_print_char_opendocument(out, source[t->start + 1]);
+ mmd_print_char_opendocument(out, source[t->start + 1], false);
}
break;
void mmd_export_link_opendocument(DString * out, const char * source, token * text, link * link, scratch_pad * scratch) {
if (link->url) {
print_const("<text:a xlink:type=\"simple\" xlink:href=\"");
- mmd_print_string_opendocument(out, link->url);
+ mmd_print_string_opendocument(out, link->url, false);
print_const("\"");
} else {
print_const("<a xlink:type=\"simple\" xlink:href=\"\"");
if (link->title && link->title[0] != '\0') {
print_const(" office:name=\"");
- mmd_print_string_opendocument(out, link->title);
+ mmd_print_string_opendocument(out, link->title, false);
print_const("\"");
}
(source[t->start + 1] == ' ')) {
print_const(" "); // This is a non-breaking space character
} else {
- mmd_print_char_opendocument(out, source[t->start + 1]);
+ mmd_print_char_opendocument(out, source[t->start + 1], false);
}
break;
temp_bool = false;
}
- mmd_print_string_opendocument(out, temp_char);
+ mmd_print_string_opendocument(out, temp_char, false);
print_const("\">");
- mmd_print_string_opendocument(out, temp_char);
+ mmd_print_string_opendocument(out, temp_char, false);
print_const("</text:a>");
} else if (scan_html(&source[t->start])) {
// We ignore HTML blocks
if (temp_short3 == scratch->inline_abbreviations_to_free->size) {
// This is a reference definition
- mmd_print_string_opendocument(out, temp_note->label_text);
+ mmd_print_string_opendocument(out, temp_note->label_text, true);
// mmd_export_token_tree_opendocument(out, source, t->child, scratch);
} else {
// This is an inline definition
- mmd_print_string_opendocument(out, temp_note->label_text);
+ mmd_print_string_opendocument(out, temp_note->label_text, true);
// mmd_export_token_tree_opendocument(out, source, t->child, scratch);
}
} else {
if (temp_short3 == scratch->inline_abbreviations_to_free->size) {
// This is a reference definition
- mmd_print_string_opendocument(out, temp_note->clean_text);
+ mmd_print_string_opendocument(out, temp_note->clean_text, true);
print_const(" (");
- mmd_print_string_opendocument(out, temp_note->label_text);
+ mmd_print_string_opendocument(out, temp_note->label_text, true);
print_const(")");
} else {
// This is an inline definition
- mmd_print_string_opendocument(out, temp_note->clean_text);
+ mmd_print_string_opendocument(out, temp_note->clean_text, true);
print_const(" (");
- mmd_print_string_opendocument(out, temp_note->label_text);
+ mmd_print_string_opendocument(out, temp_note->label_text, true);
print_const(")");
}
if (temp_short2 == scratch->used_glossaries->size) {
// This is a re-use of a previously used note
- mmd_print_string_opendocument(out, temp_note->clean_text);
+ mmd_print_string_opendocument(out, temp_note->clean_text, true);
} else {
// This is the first time this note was used
- mmd_print_string_opendocument(out, temp_note->clean_text);
+ mmd_print_string_opendocument(out, temp_note->clean_text, true);
printf("<text:note text:id=\"gn%d\" text:note-class=\"glossary\"><text:note-body>", temp_short);
mmd_export_token_tree_opendocument(out, source, temp_note->content, scratch);
temp_char2 = extract_metadata(scratch, temp_char);
if (temp_char2) {
- mmd_print_string_opendocument(out, temp_char2);
+ mmd_print_string_opendocument(out, temp_char2, true);
} else {
mmd_export_token_tree_opendocument(out, source, t->child, scratch);
}
#include "writer.h"
-void mmd_print_char_opendocument(DString * out, char c);
-void mmd_print_string_opendocument(DString * out, const char * str);
+void mmd_print_char_opendocument(DString * out, char c, bool line_breaks);
+void mmd_print_string_opendocument(DString * out, const char * str, bool line_breaks);
void mmd_print_localized_char_opendocument(DString * out, unsigned short type, scratch_pad * scratch);
void mmd_export_token_opendocument_raw(DString * out, const char * source, token * t, scratch_pad * scratch);
for (m = scratch->meta_hash; m != NULL; m = m->hh.next) {
if (strcmp(m->key, "author") == 0) {
print_const("\t<dc:creator>");
- mmd_print_string_opendocument(out, m->value);
+ mmd_print_string_opendocument(out, m->value, false);
print_const("</dc:creator>\n");
} else if (strcmp(m->key, "baseheaderlevel") == 0) {
} else if (strcmp(m->key, "bibliostyle") == 0) {
} else if (strcmp(m->key, "mmdfooter") == 0) {
} else if (strcmp(m->key, "mmdheader") == 0) {
} else if (strcmp(m->key, "odfheader") == 0) {
- mmd_print_string_opendocument(out, m->value);
+ mmd_print_string_opendocument(out, m->value, false);
} else if (strcmp(m->key, "quoteslanguage") == 0) {
} else if (strcmp(m->key, "title") == 0) {
print_const("\t<dc:title>");
- mmd_print_string_opendocument(out, m->value);
+ mmd_print_string_opendocument(out, m->value, false);
print_const("</dc:title>\n");
} else if (strcmp(m->key, "transcludebase") == 0) {
} else if (strcmp(m->key, "xhtmlheader") == 0) {
} else if (strcmp(m->key, "xhtmlheaderlevel") == 0) {
} else {
print_const("\t<meta:user-defined meta:name=\"");
- mmd_print_string_opendocument(out, m->key);
+ mmd_print_string_opendocument(out, m->key, false);
print_const("\">");
- mmd_print_string_opendocument(out, m->value);
+ mmd_print_string_opendocument(out, m->value, false);
print_const("</meta:user-defined>\n");
}
}
<dc:title>*foo* "bar"</dc:title>
<meta:user-defined meta:name="empty"></meta:user-defined>
<meta:user-defined meta:name="foo">bar foo bar foo bar</meta:user-defined>
- <meta:user-defined meta:name="multiline">first line<text:line-break/>
+ <meta:user-defined meta:name="multiline">first line
second line</meta:user-defined>
</office:meta>
<office:body>
<link type="text/css" rel="stylesheet" href="http://foo.com/bar.css"/>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
<meta name="foo" content="bar foo bar foo bar"/>
- <meta name="multiline" content="first line<br/>
+ <meta name="multiline" content="first line
second line"/>
</head>
<body>
<text:p text:style-name="Standard"><text:a xlink:type="simple" xlink:href="http://test.0/">foo</text:a>
<text:a xlink:type="simple" xlink:href="http://test.1/file.txt">bar</text:a></text:p>
+
+<text:p text:style-name="Standard"><text:a xlink:type="simple" xlink:href="http://daringfireball.net/projects/markdown/" office:name="Daring Fireball:
+Markdown">Markdown</text:a></text:p>
</office:text>
</office:body>
</office:document>
<p><a href="http://test.0/">foo</a>
<a href="http://test.1/file.txt">bar</a></p>
+<p><a href="http://daringfireball.net/projects/markdown/" title="Daring Fireball:
+Markdown">Markdown</a></p>
+
</body>
</html>
<p><a href="http://test.0/">foo</a>
<a href="http://test.1/file.txt">bar</a></p>
+
+<p>[Markdown]</p>
<opml version="1.0">
<head><title>Reference Links</title></head>
<body>
-<outline text=">>Preamble<<" _note=" [*foo*][bar]. [*foo*][BAR]. [*foo*][foobar]. [*foo*][foo bar]. [*foo*][foo bar]. 5 [*foo*][long]. [foo][]. [foo]. [[foo]][bar] [[foo]][] 10 [[foo][bar]][] [foo][bar] [foo] [bar] [foo] [bar] [foo]: http://test.0/ [bar]:	http://test.1/file.txt [BAR]: http://test.2/ [foobar]: http://test.3/file.txt	"title" [foo bar]: http://test.4/ [foo bar]: http://test.5/	"" [long]: http://test.6/ "title" "></outline>
+<outline text=">>Preamble<<" _note=" [*foo*][bar]. [*foo*][BAR]. [*foo*][foobar]. [*foo*][foo bar]. [*foo*][foo bar]. 5 [*foo*][long]. [foo][]. [foo]. [[foo]][bar] [[foo]][] 10 [[foo][bar]][] [foo][bar] [foo] [bar] [foo] [bar] [Markdown] [foo]: http://test.0/ [bar]:	http://test.1/file.txt [BAR]: http://test.2/ [foobar]: http://test.3/file.txt	"title" [foo bar]: http://test.4/ [foo bar]: http://test.5/	"" [long]: http://test.6/ "title" [Markdown]:	http://daringfireball.net/projects/markdown/ "Daring Fireball: Markdown" "></outline>
<outline text=">>Metadata<<">
<outline text="title" _note="Reference Links"/>
<outline text="latexconfig" _note="article"/>
\href{http://test.0/}{foo}\footnote{\href{http://test.0/}{http:\slash \slash test.0\slash }}
\href{http://test.1/file.txt}{bar}\footnote{\href{http://test.1/file.txt}{http:\slash \slash test.1\slash file.txt}}
+\href{http://daringfireball.net/projects/markdown/}{Markdown}\footnote{\href{http://daringfireball.net/projects/markdown/}{http:\slash \slash daringfireball.net\slash projects\slash markdown\slash }}
+
\input{mmd6-article-footer}
\end{document}
[foo]
[bar]
+[Markdown]
+
[foo]: http://test.0/
[bar]: http://test.1/file.txt
[foo bar]: http://test.5/ ""
[long]: http://test.6/
"title"
+[Markdown]: http://daringfireball.net/projects/markdown/ "Daring Fireball:
+Markdown"