<dc:title>MultiMarkdown v6 Quick Start Guide</dc:title>
<meta:user-defined meta:name="author">Fletcher T. Penney</meta:user-defined>
<meta:user-defined meta:name="version">6.0-b</meta:user-defined>
+ <meta:user-defined meta:name="uuid">0d6313fa-9135-477e-9c14-7d62c1977833</meta:user-defined>
</office:meta>
<office:body>
<office:text>
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#citations" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Citations <text:tab/>1</text:a></text:p>
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#criticmarkup" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">CriticMarkup <text:tab/>1</text:a></text:p>
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#emphandstrong" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Emph and Strong <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#epub3support" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">EPUB 3 Support <text:tab/>1</text:a></text:p>
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#fencedcodeblocks" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Fenced Code Blocks <text:tab/>1</text:a></text:p>
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#glossaryterms" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Glossary Terms <text:tab/>1</text:a></text:p>
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#internationalization" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Internationalization <text:tab/>1</text:a></text:p>
engine has been improved to be more accurate, particularly in various edge
cases where proper parsing can be difficult.</text:p>
+<text:h text:outline-level="4"><text:bookmark text:name="epub3support"/>EPUB 3 Support </text:h>
+
+<text:p text:style-name="Standard">MMD v6 now provides support for direct creation of <text:a xlink:type="simple" xlink:href="https://en.wikipedia.org/wiki/EPUB">EPUB 3</text:a> files. Previously
+a separate tool was required to create EPUB files from MMD. It’s now built-
+in. Currently, EPUB 3 files are built using the usual HTML 5 output. No
+extra CSS is applied, so the default from the reader will be used. Images are
+not yet supported, but are planned for the future.</text:p>
+
+<text:p text:style-name="Standard">EPUB files can be highly customized with other tools, and I recommend doing
+that for production quality files. For example, apparently performance is
+improved when the content is divided into multiple files (e.g. one file per
+chapter). MMD creates EPUB 3 files using a single file. Tools like <text:a xlink:type="simple" xlink:href="https://sigil-ebook.com/">Sigil</text:a>
+are useful for improving your EPUB files, and I recommend doing that.</text:p>
+
+<text:p text:style-name="Standard">Not all EPUB readers support v3 files. I don’t plan on adding support for
+older versions of the EPUB format, but other tools can convert to other
+document formats you need. Same goes for Amazon’s ebook formats – the
+<text:a xlink:type="simple" xlink:href="https://calibre-ebook.com/">Calibre</text:a> program can also be used to interconvert between formats.</text:p>
+
+<text:p text:style-name="Standard">**NOTE: Because EPUB documents are binary files, MMD only creates them when
+**run in batch mode (using the <text:span text:style-name="Source_20_Text">-b\--batch</text:span> options). Otherwise, it simply
+**outputs the HTML 5 file that would serve as the primary content for the
+**EPUB.</text:p>
+
<text:h text:outline-level="4"><text:bookmark text:name="fencedcodeblocks"/>Fenced Code Blocks </text:h>
<text:p text:style-name="Standard">Fenced code blocks are fundamentally the same as MMD v5, except:</text:p>
<!DOCTYPE html>
-<html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="utf-8"/>
<title>MultiMarkdown v6 Quick Start Guide</title>
<meta name="author" content="Fletcher T. Penney"/>
<meta name="version" content="6.0-b"/>
+ <meta name="uuid" content="0d6313fa-9135-477e-9c14-7d62c1977833"/>
</head>
<body>
<li><a href="#citations">Citations </a></li>
<li><a href="#criticmarkup">CriticMarkup </a></li>
<li><a href="#emphandstrong">Emph and Strong </a></li>
+<li><a href="#epub3support">EPUB 3 Support </a></li>
<li><a href="#fencedcodeblocks">Fenced Code Blocks </a></li>
<li><a href="#glossaryterms">Glossary Terms </a></li>
<li><a href="#internationalization">Internationalization </a></li>
engine has been improved to be more accurate, particularly in various edge
cases where proper parsing can be difficult.</p>
+<h4 id="epub3support">EPUB 3 Support </h4>
+
+<p><abbr title="MultiMarkdown">MMD</abbr> v6 now provides support for direct creation of <a href="https://en.wikipedia.org/wiki/EPUB">EPUB 3</a> files. Previously
+a separate tool was required to create EPUB files from <abbr title="MultiMarkdown">MMD</abbr>. It’s now built-
+in. Currently, EPUB 3 files are built using the usual HTML 5 output. No
+extra CSS is applied, so the default from the reader will be used. Images are
+not yet supported, but are planned for the future.</p>
+
+<p>EPUB files can be highly customized with other tools, and I recommend doing
+that for production quality files. For example, apparently performance is
+improved when the content is divided into multiple files (e.g. one file per
+chapter). <abbr title="MultiMarkdown">MMD</abbr> creates EPUB 3 files using a single file. Tools like <a href="https://sigil-ebook.com/">Sigil</a>
+are useful for improving your EPUB files, and I recommend doing that.</p>
+
+<p>Not all EPUB readers support v3 files. I don’t plan on adding support for
+older versions of the EPUB format, but other tools can convert to other
+document formats you need. Same goes for Amazon’s ebook formats – the
+<a href="https://calibre-ebook.com/">Calibre</a> program can also be used to interconvert between formats.</p>
+
+<p>**NOTE: Because EPUB documents are binary files, <abbr title="MultiMarkdown">MMD</abbr> only creates them when
+**run in batch mode (using the <code>-b\--batch</code> options). Otherwise, it simply
+**outputs the HTML 5 file that would serve as the primary content for the
+**EPUB.</p>
+
<h4 id="fencedcodeblocks">Fenced Code Blocks </h4>
<p>Fenced code blocks are fundamentally the same as <abbr title="MultiMarkdown">MMD</abbr> v5, except:</p>
cases where proper parsing can be difficult.
+## EPUB 3 Support ##
+
+MMD v6 now provides support for direct creation of [EPUB 3] files. Previously
+a separate tool was required to create EPUB files from MMD. It's now built-
+in. Currently, EPUB 3 files are built using the usual HTML 5 output. No
+extra CSS is applied, so the default from the reader will be used. Images are
+not yet supported, but are planned for the future.
+
+EPUB files can be highly customized with other tools, and I recommend doing
+that for production quality files. For example, apparently performance is
+improved when the content is divided into multiple files (e.g. one file per
+chapter). MMD creates EPUB 3 files using a single file. Tools like [Sigil]
+are useful for improving your EPUB files, and I recommend doing that.
+
+Not all EPUB readers support v3 files. I don't plan on adding support for
+older versions of the EPUB format, but other tools can convert to other
+document formats you need. Same goes for Amazon's ebook formats -- the
+[Calibre] program can also be used to interconvert between formats.
+
+**NOTE: Because EPUB documents are binary files, MMD only creates them when
+**run in batch mode (using the `-b\--batch` options). Otherwise, it simply
+**outputs the HTML 5 file that would serve as the primary content for the
+**EPUB.
+
+
## Fenced Code Blocks ##
Fenced code blocks are fundamentally the same as MMD v5, except:
[?PEG]: Parsing Expression Grammar <https://en.wikipedia.org/wiki/Parsing_expression_grammar>
[?AST]: Abstract Syntax Tree <https://en.wikipedia.org/wiki/Abstract_syntax_tree>
+
+[EPUB 3]: https://en.wikipedia.org/wiki/EPUB
+
+[Sigil]: https://sigil-ebook.com/
+
+[Calibre]: https://calibre-ebook.com/
void mmd_start_complete_html(DString * out, const char * source, scratch_pad * scratch) {
- print_const("<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n\t<meta charset=\"utf-8\"/>\n");
+ meta * m;
+
+ print_const("<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\"");
+ HASH_FIND_STR(scratch->meta_hash, "language", m);
+ if (m) {
+ printf(" lang=\"%s\"", m->value);
+ } else {
+ print_const(" lang=\"en\"");
+ }
+ print_const(">\n<head>\n\t<meta charset=\"utf-8\"/>\n");
// Iterate over metadata keys
- meta * m;
for (m = scratch->meta_hash; m != NULL; m = m->hh.next) {
if (strcmp(m->key, "baseheaderlevel") == 0) {
#include "argtable3.h"
#include "critic_markup.h"
#include "d_string.h"
+#include "epub.h"
#include "i18n.h"
#include "libMultiMarkdown.h"
#include "html.h"
a_rem1 = arg_rem("", ""),
- a_format = arg_str0("t", "to", "FORMAT", "convert to FORMAT, FORMAT = html|latex|beamer|memoir|mmd|odf"),
+ a_format = arg_str0("t", "to", "FORMAT", "convert to FORMAT, FORMAT = html|latex|beamer|memoir|mmd|odf|epub"),
a_o = arg_file0("o", "output", "FILE", "send output to FILE"),
a_batch = arg_lit0("b", "batch", "process each file separately"),
format = FORMAT_MMD;
else if (strcmp(a_format->sval[0], "odf") == 0)
format = FORMAT_ODF;
+ else if (strcmp(a_format->sval[0], "epub") == 0)
+ format = FORMAT_EPUB;
else {
// No valid format found
fprintf(stderr, "%s: Unknown output format '%s'\n", binname, a_format->sval[0]);
case FORMAT_MMD:
output_filename = filename_with_extension(a_file->filename[i], ".mmdtext");
break;
+ case FORMAT_EPUB:
+ output_filename = filename_with_extension(a_file->filename[i], ".epub");
+ break;
}
// Perform transclusion(s)
token_pool_init();
#endif
- if (FORMAT_MMD == format) {
+ if (FORMAT_EPUB == format) {
+ mmd_write_to_file(buffer, extensions, format, language, output_filename);
+ result = NULL;
+ } else if (FORMAT_MMD == format) {
result = buffer->str;
} else {
result = mmd_convert_d_string(buffer, extensions, format, language);
}
- if (!(output_stream = fopen(output_filename, "w"))) {
- // Failed to open file
- perror(output_filename);
- } else {
- fputs(result, output_stream);
- fputc('\n', output_stream);
- fclose(output_stream);
+ if (result) {
+ if (!(output_stream = fopen(output_filename, "w"))) {
+ // Failed to open file
+ perror(output_filename);
+ } else {
+ fputs(result, output_stream);
+ fputc('\n', output_stream);
+ fclose(output_stream);
+ }
}
d_string_free(buffer, true);