Skip to content

Commit 7dd192d

Browse files
committed
Merge branch 'release/6.3.1'
2 parents c360422 + 715c106 commit 7dd192d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+41039
-22223
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ cmake_minimum_required (VERSION 2.6)
88
set (My_Project_Title "MultiMarkdown")
99
set (My_Project_Description "Lightweight markup processor to produce HTML, LaTeX, and more.")
1010
set (My_Project_Author "Fletcher T. Penney")
11-
set (My_Project_Revised_Date "2018-02-05")
11+
set (My_Project_Revised_Date "2018-03-27")
1212
set (My_Project_Version_Major 6)
1313
set (My_Project_Version_Minor 3)
14-
set (My_Project_Version_Patch 0)
14+
set (My_Project_Version_Patch 1)
1515

1616
set (My_Project_Version "${My_Project_Version_Major}.${My_Project_Version_Minor}.${My_Project_Version_Patch}")
1717

@@ -647,6 +647,10 @@ ADD_MMD_TEST(mmd-6-compat "-c" MMD6Tests htmlc)
647647

648648
ADD_MMD_TEST(mmd-6-latex "-t latex" MMD6Tests tex)
649649

650+
ADD_MMD_TEST(mmd-6-beamer "-t beamer" Beamer tex)
651+
652+
ADD_MMD_TEST(mmd-6-memoir "-t memoir" Memoir tex)
653+
650654
ADD_MMD_TEST(mmd-6-odf "-t fodt" MMD6Tests fodt)
651655

652656
ADD_MMD_TEST(mmd-6-critic-accept "-a" CriticMarkup htmla)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ windows-32: $(BUILD_DIR)
8787
.PHONY : windows-zip-32
8888
windows-zip-32: $(BUILD_DIR)
8989
cd $(BUILD_DIR); touch README.html; \
90-
cmake -DCMAKE_TOOLCHAIN_FILE=../tools/Toolchain-mingw32.cmake -DCMAKE_BUILD_TYPE=Release -DZIP=1 ..
90+
cmake -DCMAKE_TOOLCHAIN_FILE=../tools/Toolchain-MinGW-w64-32bit.cmake -DCMAKE_BUILD_TYPE=Release -DZIP=1 ..
9191

9292
# Build the documentation using doxygen
9393
.PHONY : documentation

QuickStart/QuickStart.epub

1.11 KB
Binary file not shown.

QuickStart/QuickStart.fodt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ office:mimetype="application/vnd.oasis.opendocument.text">
311311
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#tableofcontents" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Table of Contents <text:tab/>1</text:a></text:p>
312312
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#tables" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Tables <text:tab/>1</text:a></text:p>
313313
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#transclusion" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Transclusion <text:tab/>1</text:a></text:p>
314+
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#developernotes" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Developer Notes <text:tab/>1</text:a></text:p>
315+
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#objectpools" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Object Pools <text:tab/>1</text:a></text:p>
316+
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#htmlbooleanattributes" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">HTML Boolean Attributes <text:tab/>1</text:a></text:p>
314317
<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#futuresteps" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Future Steps <text:tab/>1</text:a></text:p>
315318
</text:index-body>
316319
</text:table-of-content>
@@ -902,6 +905,75 @@ whether a file is being processed by itself or as part of a &#8220;parent&#8221;
902905
This can be useful when a particular file can either be a standalone document,
903906
or a chapter inside a larger document.</text:p>
904907

908+
<text:h text:outline-level="3"><text:bookmark text:name="developernotes"/>Developer Notes </text:h>
909+
910+
<text:p text:style-name="Standard">If you&#8217;re using MMD as a library in another application, there are a few
911+
things to be aware of.</text:p>
912+
913+
<text:h text:outline-level="4"><text:bookmark text:name="objectpools"/>Object Pools </text:h>
914+
915+
<text:p text:style-name="Standard">To improve performance, MMD has the option to allocate the memory for the
916+
tokens used in parsing in large chunks (&#8220;object pools&#8221;). Allocating a single
917+
large chunk of memory is more efficient than allocating many smaller chunks.
918+
However, this does complicate memory management.</text:p>
919+
920+
<text:p text:style-name="Standard">By default <text:span text:style-name="Source_20_Text">token.h</text:span> defines <text:span text:style-name="Source_20_Text">kUseObjectPool</text:span> which enables this performance
921+
improvement. This does require more caution with the way that memory is
922+
managed. (See <text:span text:style-name="Source_20_Text">main.c</text:span> for an example of how the object pool is allocated and
923+
drained.) I recommend disabling object pools unless you really understand C
924+
memory management, and understand MultiMarkdown&#8217;s program flow. Failure to
925+
properly manage the object pool can lead to massive memory leaks, freeing
926+
memory before that is still in use, or other potential problems.</text:p>
927+
928+
<text:h text:outline-level="4"><text:bookmark text:name="htmlbooleanattributes"/>HTML Boolean Attributes </text:h>
929+
930+
<text:p text:style-name="Standard">Most HTML attributes are of the key-value type (e.g. <text:span text:style-name="Source_20_Text">key=&quot;value&quot;</text:span>). But some
931+
less frequently used attributes are boolean attributes (e.g. <text:span text:style-name="Source_20_Text">&lt;video<text:line-break/>controls&gt;</text:span>). Properly distinguishing HTML from other uses of the <text:span text:style-name="Source_20_Text">&lt;</text:span>
932+
character requires matching both types under certain circumstances.</text:p>
933+
934+
<text:p text:style-name="Standard">There are some trade-offs to be made:</text:p>
935+
936+
<text:list text:style-name="L1">
937+
<text:list-item>
938+
<text:p text:style-name="Standard">Performance when compiling MultiMarkdown</text:p></text:list-item>
939+
940+
<text:list-item>
941+
<text:p text:style-name="Standard">Performance when processing parts of documents that are <text:span text:style-name="MMD-Italic">not</text:span> HTML</text:p></text:list-item>
942+
943+
<text:list-item>
944+
<text:p text:style-name="Standard">Accuracy when matching HTML</text:p></text:list-item>
945+
946+
</text:list>
947+
948+
<text:p text:style-name="Standard">So far, there seem to be four main approaches:</text:p>
949+
950+
<text:list text:style-name="L1">
951+
<text:list-item>
952+
<text:p text:style-name="Standard">Ignore boolean attributes &#8211; this is how MMD-6 started. This is fast, but
953+
not accurate for some users. Several users found issues with the <text:span text:style-name="Source_20_Text">&lt;video&gt;</text:span> tag
954+
when MMD was used in HTML heavy documents.</text:p></text:list-item>
955+
956+
<text:list-item>
957+
<text:p text:style-name="Standard">Use regexp to match all boolean attributes. This is fast to compile, but
958+
adds roughly 5&#8211;8% processing time (probably due to false positive HTML
959+
matches). This <text:span text:style-name="MMD-Italic">may</text:span> cause some text to be classified as HTML when it
960+
shouldn&#8217;t.</text:p></text:list-item>
961+
962+
<text:list-item>
963+
<text:p text:style-name="Standard">Explicitly match all possible boolean attributes &#8211; This would presumably be
964+
relatively fast when processing (due to the nature of re2c lexers), but it may
965+
be prohibitively slow to compile for some users. As someone who compiles MMD
966+
frequently, it is too slow to compile be useful for me during development.</text:p></text:list-item>
967+
968+
<text:list-item>
969+
<text:p text:style-name="Standard">Use a hand-curated list of boolean attributes that are most commonly used &#8211;
970+
this does not incur much of a performance hit when parsing, and compiles
971+
faster than the complete list of all boolean attributes. For now, this is the
972+
option I have chosen as default for MMD &#8211; it seems to be a reasonable trade-
973+
off. I will continue to research additional options.</text:p></text:list-item>
974+
975+
</text:list>
976+
905977
<text:h text:outline-level="3"><text:bookmark text:name="futuresteps"/>Future Steps </text:h>
906978

907979
<text:p text:style-name="Standard">Some features I plan to implement at some point:</text:p>

QuickStart/QuickStart.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
<li><a href="#transclusion">Transclusion </a></li>
3838
</ul>
3939
</li>
40+
<li><a href="#developernotes">Developer Notes </a>
41+
<ul>
42+
<li><a href="#objectpools">Object Pools </a></li>
43+
<li><a href="#htmlbooleanattributes">HTML Boolean Attributes </a></li>
44+
</ul>
45+
</li>
4046
<li><a href="#futuresteps">Future Steps </a></li>
4147
</ul>
4248
</div>
@@ -543,6 +549,62 @@ <h4 id="transclusion">Transclusion </h4>
543549
This can be useful when a particular file can either be a standalone document,
544550
or a chapter inside a larger document.</p>
545551

552+
<h3 id="developernotes">Developer Notes </h3>
553+
554+
<p>If you&#8217;re using <abbr title="MultiMarkdown">MMD</abbr> as a library in another application, there are a few
555+
things to be aware of.</p>
556+
557+
<h4 id="objectpools">Object Pools </h4>
558+
559+
<p>To improve performance, <abbr title="MultiMarkdown">MMD</abbr> has the option to allocate the memory for the
560+
tokens used in parsing in large chunks (&#8220;object pools&#8221;). Allocating a single
561+
large chunk of memory is more efficient than allocating many smaller chunks.
562+
However, this does complicate memory management.</p>
563+
564+
<p>By default <code>token.h</code> defines <code>kUseObjectPool</code> which enables this performance
565+
improvement. This does require more caution with the way that memory is
566+
managed. (See <code>main.c</code> for an example of how the object pool is allocated and
567+
drained.) I recommend disabling object pools unless you really understand C
568+
memory management, and understand MultiMarkdown&#8217;s program flow. Failure to
569+
properly manage the object pool can lead to massive memory leaks, freeing
570+
memory before that is still in use, or other potential problems.</p>
571+
572+
<h4 id="htmlbooleanattributes">HTML Boolean Attributes </h4>
573+
574+
<p>Most HTML attributes are of the key-value type (e.g. <code>key=&quot;value&quot;</code>). But some
575+
less frequently used attributes are boolean attributes (e.g. <code>&lt;video
576+
controls&gt;</code>). Properly distinguishing HTML from other uses of the <code>&lt;</code>
577+
character requires matching both types under certain circumstances.</p>
578+
579+
<p>There are some trade-offs to be made:</p>
580+
581+
<ul>
582+
<li><p>Performance when compiling MultiMarkdown</p></li>
583+
<li><p>Performance when processing parts of documents that are <em>not</em> HTML</p></li>
584+
<li><p>Accuracy when matching HTML</p></li>
585+
</ul>
586+
587+
<p>So far, there seem to be four main approaches:</p>
588+
589+
<ul>
590+
<li><p>Ignore boolean attributes &#8211; this is how <abbr title="MultiMarkdown">MMD</abbr>-6 started. This is fast, but
591+
not accurate for some users. Several users found issues with the <code>&lt;video&gt;</code> tag
592+
when <abbr title="MultiMarkdown">MMD</abbr> was used in HTML heavy documents.</p></li>
593+
<li><p>Use regexp to match all boolean attributes. This is fast to compile, but
594+
adds roughly 5&#8211;8% processing time (probably due to false positive HTML
595+
matches). This <em>may</em> cause some text to be classified as HTML when it
596+
shouldn&#8217;t.</p></li>
597+
<li><p>Explicitly match all possible boolean attributes &#8211; This would presumably be
598+
relatively fast when processing (due to the nature of re2c lexers), but it may
599+
be prohibitively slow to compile for some users. As someone who compiles <abbr title="MultiMarkdown">MMD</abbr>
600+
frequently, it is too slow to compile be useful for me during development.</p></li>
601+
<li><p>Use a hand-curated list of boolean attributes that are most commonly used &#8211;
602+
this does not incur much of a performance hit when parsing, and compiles
603+
faster than the complete list of all boolean attributes. For now, this is the
604+
option I have chosen as default for <abbr title="MultiMarkdown">MMD</abbr> &#8211; it seems to be a reasonable trade-
605+
off. I will continue to research additional options.</p></li>
606+
</ul>
607+
546608
<h3 id="futuresteps">Future Steps </h3>
547609

548610
<p>Some features I plan to implement at some point:</p>

QuickStart/QuickStart.pdf

4.15 KB
Binary file not shown.

QuickStart/QuickStart.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,66 @@ This can be useful when a particular file can either be a standalone document,
491491
or a chapter inside a larger document.
492492

493493

494+
# Developer Notes #
495+
496+
If you're using MMD as a library in another application, there are a few
497+
things to be aware of.
498+
499+
500+
## Object Pools ##
501+
502+
To improve performance, MMD has the option to allocate the memory for the
503+
tokens used in parsing in large chunks ("object pools"). Allocating a single
504+
large chunk of memory is more efficient than allocating many smaller chunks.
505+
However, this does complicate memory management.
506+
507+
By default `token.h` defines `kUseObjectPool` which enables this performance
508+
improvement. This does require more caution with the way that memory is
509+
managed. (See `main.c` for an example of how the object pool is allocated and
510+
drained.) I recommend disabling object pools unless you really understand C
511+
memory management, and understand MultiMarkdown's program flow. Failure to
512+
properly manage the object pool can lead to massive memory leaks, freeing
513+
memory before that is still in use, or other potential problems.
514+
515+
516+
## HTML Boolean Attributes ##
517+
518+
Most HTML attributes are of the key-value type (e.g. `key="value"`). But some
519+
less frequently used attributes are boolean attributes (e.g. `<video
520+
controls>`). Properly distinguishing HTML from other uses of the `<`
521+
character requires matching both types under certain circumstances.
522+
523+
There are some trade-offs to be made:
524+
525+
* Performance when compiling MultiMarkdown
526+
527+
* Performance when processing parts of documents that are *not* HTML
528+
529+
* Accuracy when matching HTML
530+
531+
So far, there seem to be four main approaches:
532+
533+
* Ignore boolean attributes -- this is how MMD-6 started. This is fast, but
534+
not accurate for some users. Several users found issues with the `<video>` tag
535+
when MMD was used in HTML heavy documents.
536+
537+
* Use regexp to match all boolean attributes. This is fast to compile, but
538+
adds roughly 5-8% processing time (probably due to false positive HTML
539+
matches). This *may* cause some text to be classified as HTML when it
540+
shouldn't.
541+
542+
* Explicitly match all possible boolean attributes -- This would presumably be
543+
relatively fast when processing (due to the nature of re2c lexers), but it may
544+
be prohibitively slow to compile for some users. As someone who compiles MMD
545+
frequently, it is too slow to compile be useful for me during development.
546+
547+
* Use a hand-curated list of boolean attributes that are most commonly used --
548+
this does not incur much of a performance hit when parsing, and compiles
549+
faster than the complete list of all boolean attributes. For now, this is the
550+
option I have chosen as default for MMD -- it seems to be a reasonable trade-
551+
off. I will continue to research additional options.
552+
553+
494554
# Future Steps #
495555

496556
Some features I plan to implement at some point:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
| ---------- | ------------------------- |
55
| Title: | MultiMarkdown |
66
| Author: | Fletcher T. Penney |
7-
| Date: | 2018-02-05 |
7+
| Date: | 2018-03-27 |
88
| Copyright: | Copyright © 2016 - 2018 Fletcher T. Penney. |
9-
| Version: | 6.3.0 |
9+
| Version: | 6.3.1 |
1010

1111
master branch: [![Build Status](https://travis-ci.org/fletcher/MultiMarkdown-6.svg?branch=master)](https://travis-ci.org/fletcher/MultiMarkdown-6)
1212
develop branch: [![Build Status](https://travis-ci.org/fletcher/MultiMarkdown-6.svg?branch=develop)](https://travis-ci.org/fletcher/MultiMarkdown-6)

Sources/libMultiMarkdown/beamer.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
#include "latex.h"
5757
#include "beamer.h"
58+
#include "parser.h"
5859

5960
#define print(x) d_string_append(out, x)
6061
#define print_const(x) d_string_append_c_array(out, x, sizeof(x) - 1)
@@ -173,6 +174,33 @@ void mmd_export_token_beamer(DString * out, const char * source, token * t, scra
173174
temp_char = get_fence_language_specifier(t->child->child, source);
174175

175176
if (temp_char) {
177+
if (strncmp("{=", temp_char, 2) == 0) {
178+
// Raw source
179+
if (raw_filter_text_matches(temp_char, FORMAT_BEAMER)) {
180+
switch (t->child->tail->type) {
181+
case LINE_FENCE_BACKTICK_3:
182+
case LINE_FENCE_BACKTICK_4:
183+
case LINE_FENCE_BACKTICK_5:
184+
temp_token = t->child->tail;
185+
break;
186+
187+
default:
188+
temp_token = NULL;
189+
}
190+
191+
if (temp_token) {
192+
d_string_append_c_array(out, &source[t->child->next->start], temp_token->start - t->child->next->start);
193+
scratch->padded = 1;
194+
} else {
195+
d_string_append_c_array(out, &source[t->child->start + t->child->len], t->start + t->len - t->child->next->start);
196+
scratch->padded = 0;
197+
}
198+
}
199+
200+
free(temp_char);
201+
break;
202+
}
203+
176204
printf("\\begin{lstlisting}[language=%s]\n", temp_char);
177205
} else {
178206
print_const("\\begin{verbatim}\n");

Sources/libMultiMarkdown/d_string.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,17 +650,21 @@ char * d_string_copy_substring(DString * d, size_t start, size_t len) {
650650
if (d) {
651651
char * result;
652652

653-
if ((len == -1) && (start < d->currentStringLength)) {
654-
len = d->currentStringLength - start;
655-
} else {
656-
if (start + len > d->currentStringLength) {
657-
fprintf(stderr, "d_string: Asked to copy invalid substring range.\n");
658-
fprintf(stderr, "start: %lu len: %lu string: %lu\n", start, len,
659-
d->currentStringLength);
660-
return NULL;
653+
if (len == -1) {
654+
if (start <= d->currentStringLength) {
655+
len = d->currentStringLength - start;
656+
} else {
657+
len = 0;
661658
}
662659
}
663660

661+
if (start + len > d->currentStringLength) {
662+
fprintf(stderr, "d_string: Asked to copy invalid substring range.\n");
663+
fprintf(stderr, "start: %lu len: %lu string: %lu\n", start, len,
664+
d->currentStringLength);
665+
return NULL;
666+
}
667+
664668
result = malloc(len + 1);
665669
strncpy(result, &d->str[start], len);
666670
result[len] = '\0';

0 commit comments

Comments
 (0)