]> granicus.if.org Git - multimarkdown/commitdiff
ADDED: Add {{TOC:1}} and {{TOC:1-2}} options
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 29 Nov 2018 15:07:24 +0000 (10:07 -0500)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 29 Nov 2018 15:07:24 +0000 (10:07 -0500)
13 files changed:
Sources/libMultiMarkdown/html.c
Sources/libMultiMarkdown/include/libMultiMarkdown.h
Sources/libMultiMarkdown/latex.c
Sources/libMultiMarkdown/lexer.c
Sources/libMultiMarkdown/lexer.re
Sources/libMultiMarkdown/mmd.c
Sources/libMultiMarkdown/opendocument-content.c
tests/MMD6Tests/Table of Contents.fodt
tests/MMD6Tests/Table of Contents.html
tests/MMD6Tests/Table of Contents.htmlc
tests/MMD6Tests/Table of Contents.opml
tests/MMD6Tests/Table of Contents.tex
tests/MMD6Tests/Table of Contents.text

index 9ad8121022a519549e7fa0780831e23fd46e2827..8f9359cd2613a307036f6c1a5b086c9d3840e0f0 100644 (file)
@@ -456,7 +456,7 @@ void mmd_export_image_html(DString * out, const char * source, token * text, lin
 }
 
 
-void mmd_export_toc_entry_html(DString * out, const char * source, scratch_pad * scratch, size_t * counter, short level) {
+void mmd_export_toc_entry_html(DString * out, const char * source, scratch_pad * scratch, size_t * counter, short level, short min, short max) {
        token * entry, * next;
        short entry_level, next_level;
        char * temp_char;
@@ -469,32 +469,36 @@ void mmd_export_toc_entry_html(DString * out, const char * source, scratch_pad *
                entry = stack_peek_index(scratch->header_stack, *counter);
                entry_level = raw_level_for_header(entry);
 
-               if (entry_level >= level) {
-                       // This entry is a direct descendant of the parent
-                       scratch->label_counter = (int) * counter;
-                       temp_char = label_from_header(source, entry, scratch);
-                       printf("<li><a href=\"#%s\">", temp_char);
-                       mmd_export_token_tree_html(out, source, entry->child, scratch);
-                       print_const("</a>");
-
-                       if (*counter < scratch->header_stack->size - 1) {
-                               next = stack_peek_index(scratch->header_stack, *counter + 1);
-                               next_level = next->type - BLOCK_H1 + 1;
-
-                               if (next_level > entry_level) {
-                                       // This entry has children
-                                       (*counter)++;
-                                       mmd_export_toc_entry_html(out, source, scratch, counter, entry_level + 1);
+               if (entry_level < min || entry_level > max) {
+                       // Ignore this one
+               } else {
+                       if (entry_level >= level) {
+                               // This entry is a direct descendant of the parent
+                               scratch->label_counter = (int) * counter;
+                               temp_char = label_from_header(source, entry, scratch);
+                               printf("<li><a href=\"#%s\">", temp_char);
+                               mmd_export_token_tree_html(out, source, entry->child, scratch);
+                               print_const("</a>");
+
+                               if (*counter < scratch->header_stack->size - 1) {
+                                       next = stack_peek_index(scratch->header_stack, *counter + 1);
+                                       next_level = next->type - BLOCK_H1 + 1;
+
+                                       if (next_level > entry_level) {
+                                               // This entry has children
+                                               (*counter)++;
+                                               mmd_export_toc_entry_html(out, source, scratch, counter, entry_level + 1, min, max);
+                                       }
                                }
-                       }
 
-                       print_const("</li>\n");
-                       free(temp_char);
-               } else if (entry_level < level ) {
-                       // If entry < level, exit this level
-                       // Decrement counter first, so that we can test it again later
-                       (*counter)--;
-                       break;
+                               print_const("</li>\n");
+                               free(temp_char);
+                       } else if (entry_level < level ) {
+                               // If entry < level, exit this level
+                               // Decrement counter first, so that we can test it again later
+                               (*counter)--;
+                               break;
+                       }
                }
 
                // Increment counter
@@ -505,10 +509,10 @@ void mmd_export_toc_entry_html(DString * out, const char * source, scratch_pad *
 }
 
 
-void mmd_export_toc_html(DString * out, const char * source, scratch_pad * scratch) {
+void mmd_export_toc_html(DString * out, const char * source, scratch_pad * scratch, short min, short max) {
        size_t counter = 0;
 
-       mmd_export_toc_entry_html(out, source, scratch, &counter, 0);
+       mmd_export_toc_entry_html(out, source, scratch, &counter, 0, min, max);
 
        scratch->label_counter = 0;
 }
@@ -998,7 +1002,21 @@ void mmd_export_token_html(DString * out, const char * source, token * t, scratc
                        pad(out, 2, scratch);
                        print_const("<div class=\"TOC\">\n");
 
-                       mmd_export_toc_html(out, source, scratch);
+                       // Define range
+                       if (t->child->child->type == TOC) {
+                               temp_short = 1;
+                               temp_short2 = 6;
+                       } else {
+                               temp_short = source[t->start + 6] - '0';
+
+                               if (t->child->child->type == TOC_RANGE) {
+                                       temp_short2 = source[t->start + 8] - '0';
+                               } else {
+                                       temp_short2 = temp_short;
+                               }
+                       }
+
+                       mmd_export_toc_html(out, source, scratch, temp_short, temp_short2);
                        print_const("</div>");
                        scratch->padded = 0;
                        break;
@@ -2012,6 +2030,8 @@ parse_citation:
                case TEXT_PERIOD:
                case TEXT_PLAIN:
                case TOC:
+               case TOC_SINGLE:
+               case TOC_RANGE:
                        print_token(t);
                        break;
 
index 4a1cc613c74fbf0bb315af41485637af2aff2737..79d38568a45d6e9dc3d98fe03dbb225c3fea3f58 100644 (file)
@@ -517,6 +517,8 @@ enum token_types {
        TABLE_DIVIDER,
 
        TOC,
+       TOC_SINGLE,
+       TOC_RANGE,
 
        TEXT_BACKSLASH,
        RAW_FILTER_LEFT,
index bd0e0e361860ed216109747721cca42236f6cc66..7dc213e7d9f61baab7f98ddb9e9fea5fd3b6de71 100644 (file)
@@ -890,6 +890,22 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
 
                case BLOCK_TOC:
                        pad(out, 2, scratch);
+
+                       // Define range
+                       if (t->child->child->type == TOC) {
+                       } else {
+                               temp_short = source[t->start + 6] - '0';
+
+                               if (t->child->child->type == TOC_RANGE) {
+                                       temp_short2 = source[t->start + 8] - '0';
+                               } else {
+                                       temp_short2 = temp_short;
+                               }
+
+                               // Adjust depth for LaTeX numbering -- -1 for part, 0 for chapter
+                               printf("\\setcounter{tocdepth}{%d}\n", temp_short2 - 2);
+                       }
+
                        print_const("\\tableofcontents");
                        scratch->padded = 0;
                        break;
@@ -1958,6 +1974,17 @@ parse_citation:
                        print_const("\\{\\{TOC\\}\\}");
                        break;
 
+               case TOC_SINGLE:
+                       temp_short = source[t->start + 6] - '0';
+                       printf("\\{\\{TOC:%d\\}\\}", temp_short);
+                       break;
+
+               case TOC_RANGE:
+                       temp_short = source[t->start + 6] - '0';
+                       temp_short2 = source[t->start + 8] - '0';
+                       printf("\\{\\{TOC:%d-%d\\}\\}", temp_short, temp_short2);
+                       break;
+
                case UL:
                        print_const("\\_");
                        break;
index b04810c6f213308ff8dfa77ca5335e812d918555..67619058dc441b68e4c9a1c3debdacba7e297244 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.15.3 on Thu Sep  6 07:45:31 2018 */
+/* Generated by re2c 0.15.3 on Thu Nov 29 09:12:30 2018 */
 /**
 
        MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
@@ -138,7 +138,7 @@ yy6:
        yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case ' ':       goto yy328;
+       case ' ':       goto yy338;
        default:        goto yy7;
        }
 yy7:
@@ -147,8 +147,8 @@ yy8:
        yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case '\n':      goto yy327;
-       case ' ':       goto yy328;
+       case '\n':      goto yy337;
+       case ' ':       goto yy338;
        default:        goto yy7;
        }
 yy9:
@@ -157,8 +157,8 @@ yy9:
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
        case '\t':      goto yy71;
-       case '\n':      goto yy325;
-       case '\r':      goto yy326;
+       case '\n':      goto yy335;
+       case '\r':      goto yy336;
        case ' ':       goto yy68;
        case 0xC2:      goto yy70;
        default:        goto yy3;
@@ -166,7 +166,7 @@ yy9:
 yy10:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '[':       goto yy323;
+       case '[':       goto yy333;
        default:        goto yy3;
        }
 yy11:
@@ -182,8 +182,8 @@ yy13:
        case '\n':
        case '\r':
        case ' ':
-       case 0xC2:      goto yy278;
-       case '#':       goto yy276;
+       case 0xC2:      goto yy288;
+       case '#':       goto yy286;
        default:        goto yy14;
        }
 yy14:
@@ -191,7 +191,7 @@ yy14:
 yy15:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '$':       goto yy274;
+       case '$':       goto yy284;
        default:        goto yy16;
        }
 yy16:
@@ -203,7 +203,7 @@ yy19:
        yyaccept = 3;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case '#':       goto yy258;
+       case '#':       goto yy268;
        case '0':
        case '1':
        case '2':
@@ -263,9 +263,9 @@ yy19:
        case 'w':
        case 'x':
        case 'y':
-       case 'z':       goto yy255;
+       case 'z':       goto yy265;
        case 'A':
-       case 'a':       goto yy257;
+       case 'a':       goto yy267;
        default:        goto yy20;
        }
 yy20:
@@ -273,7 +273,7 @@ yy20:
 yy21:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '\'':      goto yy253;
+       case '\'':      goto yy263;
        default:        goto yy22;
        }
 yy22:
@@ -291,7 +291,7 @@ yy29:
        yyaccept = 4;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case '+':       goto yy250;
+       case '+':       goto yy260;
        default:        goto yy30;
        }
 yy30:
@@ -299,7 +299,7 @@ yy30:
 yy31:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '-':       goto yy242;
+       case '-':       goto yy252;
        default:        goto yy32;
        }
 yy32:
@@ -308,8 +308,8 @@ yy33:
        yyaccept = 1;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case ' ':       goto yy234;
-       case '.':       goto yy235;
+       case ' ':       goto yy244;
+       case '.':       goto yy245;
        default:        goto yy3;
        }
 yy34:
@@ -319,7 +319,7 @@ yy36:
        yyaccept = 1;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case '.':       goto yy225;
+       case '.':       goto yy235;
        case '0':
        case '1':
        case '2':
@@ -329,7 +329,7 @@ yy36:
        case '6':
        case '7':
        case '8':
-       case '9':       goto yy226;
+       case '9':       goto yy236;
        default:        goto yy3;
        }
 yy37:
@@ -339,8 +339,8 @@ yy39:
        yyaccept = 5;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case '!':       goto yy218;
-       case '<':       goto yy219;
+       case '!':       goto yy228;
+       case '<':       goto yy229;
        default:        goto yy40;
        }
 yy40:
@@ -349,7 +349,7 @@ yy41:
        yyaccept = 6;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case '=':       goto yy215;
+       case '=':       goto yy225;
        default:        goto yy42;
        }
 yy42:
@@ -360,11 +360,11 @@ yy43:
 yy45:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '#':       goto yy211;
-       case '%':       goto yy205;
-       case '>':       goto yy213;
-       case '?':       goto yy207;
-       case '^':       goto yy209;
+       case '#':       goto yy221;
+       case '%':       goto yy215;
+       case '>':       goto yy223;
+       case '?':       goto yy217;
+       case '^':       goto yy219;
        default:        goto yy46;
        }
 yy46:
@@ -372,41 +372,41 @@ yy46:
 yy47:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '\n':      goto yy128;
-       case '\r':      goto yy130;
-       case ' ':       goto yy133;
-       case '!':       goto yy193;
-       case '"':       goto yy183;
-       case '#':       goto yy163;
-       case '$':       goto yy161;
-       case '%':       goto yy159;
-       case '&':       goto yy147;
-       case '\'':      goto yy181;
-       case '(':       goto yy175;
-       case ')':       goto yy173;
-       case '*':       goto yy139;
-       case '+':       goto yy157;
-       case ',':       goto yy189;
-       case '-':       goto yy155;
-       case '.':       goto yy195;
-       case '/':       goto yy143;
-       case ':':       goto yy185;
-       case ';':       goto yy187;
-       case '<':       goto yy151;
-       case '=':       goto yy153;
-       case '>':       goto yy149;
-       case '?':       goto yy191;
-       case '@':       goto yy145;
-       case '[':       goto yy167;
-       case '\\':      goto yy131;
-       case ']':       goto yy165;
-       case '^':       goto yy141;
-       case '_':       goto yy137;
-       case '`':       goto yy179;
-       case '{':       goto yy171;
-       case '|':       goto yy135;
-       case '}':       goto yy169;
-       case '~':       goto yy177;
+       case '\n':      goto yy138;
+       case '\r':      goto yy140;
+       case ' ':       goto yy143;
+       case '!':       goto yy203;
+       case '"':       goto yy193;
+       case '#':       goto yy173;
+       case '$':       goto yy171;
+       case '%':       goto yy169;
+       case '&':       goto yy157;
+       case '\'':      goto yy191;
+       case '(':       goto yy185;
+       case ')':       goto yy183;
+       case '*':       goto yy149;
+       case '+':       goto yy167;
+       case ',':       goto yy199;
+       case '-':       goto yy165;
+       case '.':       goto yy205;
+       case '/':       goto yy153;
+       case ':':       goto yy195;
+       case ';':       goto yy197;
+       case '<':       goto yy161;
+       case '=':       goto yy163;
+       case '>':       goto yy159;
+       case '?':       goto yy201;
+       case '@':       goto yy155;
+       case '[':       goto yy177;
+       case '\\':      goto yy141;
+       case ']':       goto yy175;
+       case '^':       goto yy151;
+       case '_':       goto yy147;
+       case '`':       goto yy189;
+       case '{':       goto yy181;
+       case '|':       goto yy145;
+       case '}':       goto yy179;
+       case '~':       goto yy187;
        default:        goto yy48;
        }
 yy48:
@@ -423,7 +423,7 @@ yy53:
 yy55:
        ++YYCURSOR;
        yych = *YYCURSOR;
-       goto yy127;
+       goto yy137;
 yy56:
        { return BACKTICK; }
 yy57:
@@ -496,13 +496,13 @@ yy67:
        case 10:        goto yy76;
        case 11:        goto yy88;
        case 12:        goto yy105;
-       case 13:        goto yy229;
-       case 14:        goto yy279;
-       case 15:        goto yy286;
-       case 16:        goto yy295;
-       case 17:        goto yy302;
-       case 18:        goto yy311;
-       default:        goto yy318;
+       case 13:        goto yy239;
+       case 14:        goto yy289;
+       case 15:        goto yy296;
+       case 16:        goto yy305;
+       case 17:        goto yy312;
+       case 18:        goto yy321;
+       default:        goto yy328;
        }
 yy68:
        yyaccept = 9;
@@ -1123,7 +1123,7 @@ yy101:
 yy102:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '=':       goto yy124;
+       case '=':       goto yy134;
        default:        goto yy103;
        }
 yy103:
@@ -1188,64 +1188,111 @@ yy119:
 yy120:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '}':       goto yy121;
+       case ':':       goto yy121;
+       case '}':       goto yy122;
        default:        goto yy67;
        }
 yy121:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '}':       goto yy122;
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy125;
        default:        goto yy67;
        }
 yy122:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case '}':       goto yy123;
+       default:        goto yy67;
+       }
+yy123:
        ++YYCURSOR;
        { return TOC; }
-yy124:
-       ++YYCURSOR;
-       { return CRITIC_HI_OPEN; }
+yy125:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case '-':       goto yy126;
+       case '}':       goto yy127;
+       default:        goto yy67;
+       }
 yy126:
-       ++YYCURSOR;
-       yych = *YYCURSOR;
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy130;
+       default:        goto yy67;
+       }
 yy127:
+       yych = *++YYCURSOR;
        switch (yych) {
-       case '`':       goto yy126;
-       default:        goto yy56;
+       case '}':       goto yy128;
+       default:        goto yy67;
        }
 yy128:
        ++YYCURSOR;
-yy129:
-       { return TEXT_LINEBREAK; }
+       { return TOC_SINGLE; }
 yy130:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy128;
-       default:        goto yy129;
+       case '}':       goto yy131;
+       default:        goto yy67;
        }
 yy131:
-       ++YYCURSOR;
-       switch ((yych = *YYCURSOR)) {
-       case '(':       goto yy197;
-       case ')':       goto yy199;
-       case '[':       goto yy201;
-       case ']':       goto yy203;
-       default:        goto yy132;
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case '}':       goto yy132;
+       default:        goto yy67;
        }
 yy132:
-       { return ESCAPED_CHARACTER; }
-yy133:
        ++YYCURSOR;
-       { return ESCAPED_CHARACTER; }
-yy135:
+       { return TOC_RANGE; }
+yy134:
        ++YYCURSOR;
-       { return ESCAPED_CHARACTER; }
+       { return CRITIC_HI_OPEN; }
+yy136:
+       ++YYCURSOR;
+       yych = *YYCURSOR;
 yy137:
+       switch (yych) {
+       case '`':       goto yy136;
+       default:        goto yy56;
+       }
+yy138:
        ++YYCURSOR;
-       { return ESCAPED_CHARACTER; }
 yy139:
-       ++YYCURSOR;
-       { return ESCAPED_CHARACTER; }
+       { return TEXT_LINEBREAK; }
+yy140:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case '\n':      goto yy138;
+       default:        goto yy139;
+       }
 yy141:
        ++YYCURSOR;
+       switch ((yych = *YYCURSOR)) {
+       case '(':       goto yy207;
+       case ')':       goto yy209;
+       case '[':       goto yy211;
+       case ']':       goto yy213;
+       default:        goto yy142;
+       }
+yy142:
        { return ESCAPED_CHARACTER; }
 yy143:
        ++YYCURSOR;
@@ -1330,80 +1377,95 @@ yy195:
        { return ESCAPED_CHARACTER; }
 yy197:
        ++YYCURSOR;
-       { return MATH_PAREN_OPEN; }
+       { return ESCAPED_CHARACTER; }
 yy199:
        ++YYCURSOR;
-       { return MATH_PAREN_CLOSE; }
+       { return ESCAPED_CHARACTER; }
 yy201:
        ++YYCURSOR;
-       { return MATH_BRACKET_OPEN; }
+       { return ESCAPED_CHARACTER; }
 yy203:
        ++YYCURSOR;
-       { return MATH_BRACKET_CLOSE; }
+       { return ESCAPED_CHARACTER; }
 yy205:
        ++YYCURSOR;
-       { return BRACKET_VARIABLE_LEFT; }
+       { return ESCAPED_CHARACTER; }
 yy207:
        ++YYCURSOR;
-       { return BRACKET_GLOSSARY_LEFT; }
+       { return MATH_PAREN_OPEN; }
 yy209:
        ++YYCURSOR;
-       { return BRACKET_FOOTNOTE_LEFT; }
+       { return MATH_PAREN_CLOSE; }
 yy211:
        ++YYCURSOR;
-       { return BRACKET_CITATION_LEFT; }
+       { return MATH_BRACKET_OPEN; }
 yy213:
        ++YYCURSOR;
-       { return BRACKET_ABBREVIATION_LEFT; }
+       { return MATH_BRACKET_CLOSE; }
 yy215:
+       ++YYCURSOR;
+       { return BRACKET_VARIABLE_LEFT; }
+yy217:
+       ++YYCURSOR;
+       { return BRACKET_GLOSSARY_LEFT; }
+yy219:
+       ++YYCURSOR;
+       { return BRACKET_FOOTNOTE_LEFT; }
+yy221:
+       ++YYCURSOR;
+       { return BRACKET_CITATION_LEFT; }
+yy223:
+       ++YYCURSOR;
+       { return BRACKET_ABBREVIATION_LEFT; }
+yy225:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '}':       goto yy216;
+       case '}':       goto yy226;
        default:        goto yy67;
        }
-yy216:
+yy226:
        ++YYCURSOR;
        { return CRITIC_HI_CLOSE; }
-yy218:
+yy228:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '-':       goto yy222;
+       case '-':       goto yy232;
        default:        goto yy67;
        }
-yy219:
+yy229:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '}':       goto yy220;
+       case '}':       goto yy230;
        default:        goto yy67;
        }
-yy220:
+yy230:
        ++YYCURSOR;
        { return CRITIC_COM_CLOSE; }
-yy222:
+yy232:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '-':       goto yy223;
+       case '-':       goto yy233;
        default:        goto yy67;
        }
-yy223:
+yy233:
        ++YYCURSOR;
        { return HTML_COMMENT_START; }
-yy225:
+yy235:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
        case '\t':
-       case ' ':       goto yy231;
-       case '\n':      goto yy228;
-       case '\r':      goto yy230;
-       case 0xC2:      goto yy233;
+       case ' ':       goto yy241;
+       case '\n':      goto yy238;
+       case '\r':      goto yy240;
+       case 0xC2:      goto yy243;
        default:        goto yy67;
        }
-yy226:
+yy236:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case '.':       goto yy225;
+       case '.':       goto yy235;
        case '0':
        case '1':
        case '2':
@@ -1413,102 +1475,102 @@ yy226:
        case '6':
        case '7':
        case '8':
-       case '9':       goto yy226;
+       case '9':       goto yy236;
        default:        goto yy67;
        }
-yy228:
+yy238:
        ++YYCURSOR;
-yy229:
+yy239:
        YYCURSOR = YYCTXMARKER;
        { return TEXT_NUMBER_POSS_LIST; }
-yy230:
+yy240:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy228;
-       default:        goto yy229;
+       case '\n':      goto yy238;
+       default:        goto yy239;
        }
-yy231:
+yy241:
        yyaccept = 13;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
        case '\t':
-       case ' ':       goto yy231;
-       case 0xC2:      goto yy233;
-       default:        goto yy229;
+       case ' ':       goto yy241;
+       case 0xC2:      goto yy243;
+       default:        goto yy239;
        }
-yy233:
+yy243:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy231;
+       case 0xA0:      goto yy241;
        default:        goto yy67;
        }
-yy234:
+yy244:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '.':       goto yy238;
+       case '.':       goto yy248;
        default:        goto yy67;
        }
-yy235:
+yy245:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '.':       goto yy236;
+       case '.':       goto yy246;
        default:        goto yy67;
        }
-yy236:
+yy246:
        ++YYCURSOR;
        { return ELLIPSIS; }
-yy238:
+yy248:
        yych = *++YYCURSOR;
        switch (yych) {
-       case ' ':       goto yy239;
+       case ' ':       goto yy249;
        default:        goto yy67;
        }
-yy239:
+yy249:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '.':       goto yy240;
+       case '.':       goto yy250;
        default:        goto yy67;
        }
-yy240:
+yy250:
        ++YYCURSOR;
        { return ELLIPSIS; }
-yy242:
+yy252:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
-       case '-':       goto yy248;
-       case '>':       goto yy246;
-       case '}':       goto yy244;
-       default:        goto yy243;
+       case '-':       goto yy258;
+       case '>':       goto yy256;
+       case '}':       goto yy254;
+       default:        goto yy253;
        }
-yy243:
+yy253:
        { return DASH_N; }
-yy244:
+yy254:
        ++YYCURSOR;
        { return CRITIC_DEL_CLOSE; }
-yy246:
+yy256:
        ++YYCURSOR;
        { return HTML_COMMENT_STOP; }
-yy248:
+yy258:
        ++YYCURSOR;
        { return DASH_M; }
-yy250:
+yy260:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '}':       goto yy251;
+       case '}':       goto yy261;
        default:        goto yy67;
        }
-yy251:
+yy261:
        ++YYCURSOR;
        { return CRITIC_ADD_CLOSE; }
-yy253:
+yy263:
        ++YYCURSOR;
        { return QUOTE_RIGHT_ALT; }
-yy255:
+yy265:
        ++YYCURSOR;
        yych = *YYCURSOR;
-yy256:
+yy266:
        switch (yych) {
        case '0':
        case '1':
@@ -1571,18 +1633,18 @@ yy256:
        case 'w':
        case 'x':
        case 'y':
-       case 'z':       goto yy255;
-       case ';':       goto yy269;
+       case 'z':       goto yy265;
+       case ';':       goto yy279;
        default:        goto yy67;
        }
-yy257:
+yy267:
        yych = *++YYCURSOR;
        switch (yych) {
        case 'M':
-       case 'm':       goto yy268;
-       default:        goto yy256;
+       case 'm':       goto yy278;
+       default:        goto yy266;
        }
-yy258:
+yy268:
        yych = *++YYCURSOR;
        switch (yych) {
        case '0':
@@ -1594,18 +1656,18 @@ yy258:
        case '6':
        case '7':
        case '8':
-       case '9':       goto yy260;
+       case '9':       goto yy270;
        case 'X':
-       case 'x':       goto yy259;
+       case 'x':       goto yy269;
        default:        goto yy67;
        }
-yy259:
+yy269:
        yych = *++YYCURSOR;
        switch (yych) {
        case ';':       goto yy67;
-       default:        goto yy265;
+       default:        goto yy275;
        }
-yy260:
+yy270:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
@@ -1618,17 +1680,17 @@ yy260:
        case '6':
        case '7':
        case '8':
-       case '9':       goto yy260;
-       case ';':       goto yy262;
+       case '9':       goto yy270;
+       case ';':       goto yy272;
        default:        goto yy67;
        }
-yy262:
+yy272:
        ++YYCURSOR;
        { return HTML_ENTITY; }
-yy264:
+yy274:
        ++YYCURSOR;
        yych = *YYCURSOR;
-yy265:
+yy275:
        switch (yych) {
        case '0':
        case '1':
@@ -1677,36 +1739,36 @@ yy265:
        case 'c':
        case 'd':
        case 'e':
-       case 'f':       goto yy264;
-       case ';':       goto yy266;
+       case 'f':       goto yy274;
+       case ';':       goto yy276;
        default:        goto yy67;
        }
-yy266:
+yy276:
        ++YYCURSOR;
        { return HTML_ENTITY; }
-yy268:
+yy278:
        yych = *++YYCURSOR;
        switch (yych) {
        case 'P':
-       case 'p':       goto yy271;
-       default:        goto yy256;
+       case 'p':       goto yy281;
+       default:        goto yy266;
        }
-yy269:
+yy279:
        ++YYCURSOR;
        { return HTML_ENTITY; }
-yy271:
+yy281:
        yych = *++YYCURSOR;
        switch (yych) {
-       case ';':       goto yy272;
-       default:        goto yy256;
+       case ';':       goto yy282;
+       default:        goto yy266;
        }
-yy272:
+yy282:
        ++YYCURSOR;
        { return AMPERSAND_LONG; }
-yy274:
+yy284:
        ++YYCURSOR;
        { return MATH_DOLLAR_DOUBLE; }
-yy276:
+yy286:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
@@ -1715,79 +1777,79 @@ yy276:
        case '\n':
        case '\r':
        case ' ':
-       case 0xC2:      goto yy285;
-       case '#':       goto yy291;
+       case 0xC2:      goto yy295;
+       case '#':       goto yy301;
        default:        goto yy67;
        }
-yy277:
+yy287:
        yyaccept = 14;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
-yy278:
+yy288:
        switch (yych) {
        case 0x00:
-       case '\n':      goto yy281;
+       case '\n':      goto yy291;
        case '\t':
-       case ' ':       goto yy277;
-       case '\r':      goto yy283;
-       case 0xC2:      goto yy280;
-       default:        goto yy279;
+       case ' ':       goto yy287;
+       case '\r':      goto yy293;
+       case 0xC2:      goto yy290;
+       default:        goto yy289;
        }
-yy279:
+yy289:
        { return HASH1; }
-yy280:
+yy290:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy277;
+       case 0xA0:      goto yy287;
        default:        goto yy67;
        }
-yy281:
+yy291:
        ++YYCURSOR;
-yy282:
+yy292:
        YYCURSOR = YYCTXMARKER;
        { return HASH1; }
-yy283:
+yy293:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy281;
-       default:        goto yy282;
+       case '\n':      goto yy291;
+       default:        goto yy292;
        }
-yy284:
+yy294:
        yyaccept = 15;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
-yy285:
+yy295:
        switch (yych) {
        case 0x00:
-       case '\n':      goto yy288;
+       case '\n':      goto yy298;
        case '\t':
-       case ' ':       goto yy284;
-       case '\r':      goto yy290;
-       case 0xC2:      goto yy287;
-       default:        goto yy286;
+       case ' ':       goto yy294;
+       case '\r':      goto yy300;
+       case 0xC2:      goto yy297;
+       default:        goto yy296;
        }
-yy286:
+yy296:
        { return HASH2; }
-yy287:
+yy297:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy284;
+       case 0xA0:      goto yy294;
        default:        goto yy67;
        }
-yy288:
+yy298:
        ++YYCURSOR;
-yy289:
+yy299:
        YYCURSOR = YYCTXMARKER;
        { return HASH2; }
-yy290:
+yy300:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy288;
-       default:        goto yy289;
+       case '\n':      goto yy298;
+       default:        goto yy299;
        }
-yy291:
+yy301:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
@@ -1796,11 +1858,11 @@ yy291:
        case '\n':
        case '\r':
        case ' ':
-       case 0xC2:      goto yy294;
-       case '#':       goto yy292;
+       case 0xC2:      goto yy304;
+       case '#':       goto yy302;
        default:        goto yy67;
        }
-yy292:
+yy302:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
@@ -1809,79 +1871,79 @@ yy292:
        case '\n':
        case '\r':
        case ' ':
-       case 0xC2:      goto yy301;
-       case '#':       goto yy307;
+       case 0xC2:      goto yy311;
+       case '#':       goto yy317;
        default:        goto yy67;
        }
-yy293:
+yy303:
        yyaccept = 16;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
-yy294:
+yy304:
        switch (yych) {
        case 0x00:
-       case '\n':      goto yy297;
+       case '\n':      goto yy307;
        case '\t':
-       case ' ':       goto yy293;
-       case '\r':      goto yy299;
-       case 0xC2:      goto yy296;
-       default:        goto yy295;
+       case ' ':       goto yy303;
+       case '\r':      goto yy309;
+       case 0xC2:      goto yy306;
+       default:        goto yy305;
        }
-yy295:
+yy305:
        { return HASH3; }
-yy296:
+yy306:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy293;
+       case 0xA0:      goto yy303;
        default:        goto yy67;
        }
-yy297:
+yy307:
        ++YYCURSOR;
-yy298:
+yy308:
        YYCURSOR = YYCTXMARKER;
        { return HASH3; }
-yy299:
+yy309:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy297;
-       default:        goto yy298;
+       case '\n':      goto yy307;
+       default:        goto yy308;
        }
-yy300:
+yy310:
        yyaccept = 17;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
-yy301:
+yy311:
        switch (yych) {
        case 0x00:
-       case '\n':      goto yy304;
+       case '\n':      goto yy314;
        case '\t':
-       case ' ':       goto yy300;
-       case '\r':      goto yy306;
-       case 0xC2:      goto yy303;
-       default:        goto yy302;
+       case ' ':       goto yy310;
+       case '\r':      goto yy316;
+       case 0xC2:      goto yy313;
+       default:        goto yy312;
        }
-yy302:
+yy312:
        { return HASH4; }
-yy303:
+yy313:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy300;
+       case 0xA0:      goto yy310;
        default:        goto yy67;
        }
-yy304:
+yy314:
        ++YYCURSOR;
-yy305:
+yy315:
        YYCURSOR = YYCTXMARKER;
        { return HASH4; }
-yy306:
+yy316:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy304;
-       default:        goto yy305;
+       case '\n':      goto yy314;
+       default:        goto yy315;
        }
-yy307:
+yy317:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
@@ -1890,11 +1952,11 @@ yy307:
        case '\n':
        case '\r':
        case ' ':
-       case 0xC2:      goto yy310;
-       case '#':       goto yy308;
+       case 0xC2:      goto yy320;
+       case '#':       goto yy318;
        default:        goto yy67;
        }
-yy308:
+yy318:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
@@ -1903,97 +1965,97 @@ yy308:
        case '\n':
        case '\r':
        case ' ':
-       case 0xC2:      goto yy317;
+       case 0xC2:      goto yy327;
        default:        goto yy67;
        }
-yy309:
+yy319:
        yyaccept = 18;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
-yy310:
+yy320:
        switch (yych) {
        case 0x00:
-       case '\n':      goto yy313;
+       case '\n':      goto yy323;
        case '\t':
-       case ' ':       goto yy309;
-       case '\r':      goto yy315;
-       case 0xC2:      goto yy312;
-       default:        goto yy311;
+       case ' ':       goto yy319;
+       case '\r':      goto yy325;
+       case 0xC2:      goto yy322;
+       default:        goto yy321;
        }
-yy311:
+yy321:
        { return HASH5; }
-yy312:
+yy322:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy309;
+       case 0xA0:      goto yy319;
        default:        goto yy67;
        }
-yy313:
+yy323:
        ++YYCURSOR;
-yy314:
+yy324:
        YYCURSOR = YYCTXMARKER;
        { return HASH5; }
-yy315:
+yy325:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy313;
-       default:        goto yy314;
+       case '\n':      goto yy323;
+       default:        goto yy324;
        }
-yy316:
+yy326:
        yyaccept = 19;
        YYMARKER = ++YYCURSOR;
        yych = *YYCURSOR;
-yy317:
+yy327:
        switch (yych) {
        case 0x00:
-       case '\n':      goto yy320;
+       case '\n':      goto yy330;
        case '\t':
-       case ' ':       goto yy316;
-       case '\r':      goto yy322;
-       case 0xC2:      goto yy319;
-       default:        goto yy318;
+       case ' ':       goto yy326;
+       case '\r':      goto yy332;
+       case 0xC2:      goto yy329;
+       default:        goto yy328;
        }
-yy318:
+yy328:
        { return HASH6; }
-yy319:
+yy329:
        ++YYCURSOR;
        yych = *YYCURSOR;
        switch (yych) {
-       case 0xA0:      goto yy316;
+       case 0xA0:      goto yy326;
        default:        goto yy67;
        }
-yy320:
+yy330:
        ++YYCURSOR;
-yy321:
+yy331:
        YYCURSOR = YYCTXMARKER;
        { return HASH6; }
-yy322:
+yy332:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy320;
-       default:        goto yy321;
+       case '\n':      goto yy330;
+       default:        goto yy331;
        }
-yy323:
+yy333:
        ++YYCURSOR;
        { return BRACKET_IMAGE_LEFT; }
-yy325:
+yy335:
        yych = *++YYCURSOR;
        goto yy7;
-yy326:
+yy336:
        yych = *++YYCURSOR;
        switch (yych) {
-       case '\n':      goto yy325;
+       case '\n':      goto yy335;
        default:        goto yy7;
        }
-yy327:
+yy337:
        yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        switch (yych) {
-       case ' ':       goto yy328;
+       case ' ':       goto yy338;
        default:        goto yy7;
        }
-yy328:
+yy338:
        yych = *++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
        switch (yych) {
@@ -2120,7 +2182,7 @@ yy328:
        case '|':
        case '}':
        case '~':
-       case 0x7F:      goto yy329;
+       case 0x7F:      goto yy339;
        case 0xC2:
        case 0xC3:
        case 0xC4:
@@ -2150,8 +2212,8 @@ yy328:
        case 0xDC:
        case 0xDD:
        case 0xDE:
-       case 0xDF:      goto yy331;
-       case 0xE0:      goto yy332;
+       case 0xDF:      goto yy341;
+       case 0xE0:      goto yy342;
        case 0xE1:
        case 0xE2:
        case 0xE3:
@@ -2166,19 +2228,19 @@ yy328:
        case 0xEC:
        case 0xED:
        case 0xEE:
-       case 0xEF:      goto yy333;
-       case 0xF0:      goto yy334;
+       case 0xEF:      goto yy343;
+       case 0xF0:      goto yy344;
        case 0xF1:
        case 0xF2:
-       case 0xF3:      goto yy335;
-       case 0xF4:      goto yy336;
+       case 0xF3:      goto yy345;
+       case 0xF4:      goto yy346;
        default:        goto yy67;
        }
-yy329:
+yy339:
        ++YYCURSOR;
        YYCURSOR = YYCTXMARKER;
        { return TEXT_NL_SP; }
-yy331:
+yy341:
        yych = *++YYCURSOR;
        switch (yych) {
        case 0x80:
@@ -2244,10 +2306,10 @@ yy331:
        case 0xBC:
        case 0xBD:
        case 0xBE:
-       case 0xBF:      goto yy329;
+       case 0xBF:      goto yy339;
        default:        goto yy67;
        }
-yy332:
+yy342:
        yych = *++YYCURSOR;
        switch (yych) {
        case 0xA0:
@@ -2281,10 +2343,10 @@ yy332:
        case 0xBC:
        case 0xBD:
        case 0xBE:
-       case 0xBF:      goto yy331;
+       case 0xBF:      goto yy341;
        default:        goto yy67;
        }
-yy333:
+yy343:
        yych = *++YYCURSOR;
        switch (yych) {
        case 0x80:
@@ -2350,10 +2412,10 @@ yy333:
        case 0xBC:
        case 0xBD:
        case 0xBE:
-       case 0xBF:      goto yy331;
+       case 0xBF:      goto yy341;
        default:        goto yy67;
        }
-yy334:
+yy344:
        yych = *++YYCURSOR;
        switch (yych) {
        case 0x90:
@@ -2403,10 +2465,10 @@ yy334:
        case 0xBC:
        case 0xBD:
        case 0xBE:
-       case 0xBF:      goto yy333;
+       case 0xBF:      goto yy343;
        default:        goto yy67;
        }
-yy335:
+yy345:
        yych = *++YYCURSOR;
        switch (yych) {
        case 0x80:
@@ -2472,10 +2534,10 @@ yy335:
        case 0xBC:
        case 0xBD:
        case 0xBE:
-       case 0xBF:      goto yy333;
+       case 0xBF:      goto yy343;
        default:        goto yy67;
        }
-yy336:
+yy346:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
        case 0x80:
@@ -2493,7 +2555,7 @@ yy336:
        case 0x8C:
        case 0x8D:
        case 0x8E:
-       case 0x8F:      goto yy333;
+       case 0x8F:      goto yy343;
        default:        goto yy67;
        }
 }
index 29c1970359c7e1c08617b0739edc19fe1521c518..aec6cd2dff6fd68ef8e0f2174a4f324fe59c6c0f 100644 (file)
@@ -102,6 +102,9 @@ int scan(Scanner * s, const char * stop) {
 
                "{{TOC}}"                                               { return TOC; }
 
+               "{{TOC:" [0-9] "}}"                             { return TOC_SINGLE; }
+               "{{TOC:" [0-9] "-" [0-9] "}}"   { return TOC_RANGE; }
+
                "{++"                                                   { return CRITIC_ADD_OPEN; }
                "++}"                                                   { return CRITIC_ADD_CLOSE; }
 
index 585ffa67c77ae72bf12e70f334d5ee93ba98c3c2..874bbc0e9b45ca8b4ff9a4dca77516fecb99937f 100644 (file)
@@ -766,6 +766,8 @@ void mmd_assign_line_type(mmd_engine * e, token * line) {
                        line->type = LINE_EMPTY;
                        break;
 
+               case TOC_SINGLE:
+               case TOC_RANGE:
                case TOC:
                        line->type = (e->extensions & EXT_COMPATIBILITY) ? LINE_PLAIN : LINE_TOC;
                        break;
index 91965d581e9d934e64cbfb2d87c2bf5fa72f3324..4110849bd409ae564d583faa4e381ef98bb78a4a 100644 (file)
@@ -631,7 +631,7 @@ void mmd_export_image_opendocument(DString * out, const char * source, token * t
 }
 
 
-void mmd_export_toc_entry_opendocument(DString * out, const char * source, scratch_pad * scratch, size_t * counter, short level) {
+void mmd_export_toc_entry_opendocument(DString * out, const char * source, scratch_pad * scratch, size_t * counter, short level, short min, short max) {
        token * entry, * next;
        short entry_level, next_level;
        char * temp_char;
@@ -642,31 +642,35 @@ void mmd_export_toc_entry_opendocument(DString * out, const char * source, scrat
                entry = stack_peek_index(scratch->header_stack, *counter);
                entry_level = raw_level_for_header(entry);
 
-               if (entry_level >= level) {
-                       // This entry is a direct descendant of the parent
-                       scratch->label_counter = (int) * counter;
-                       temp_char = label_from_header(source, entry, scratch);
-                       printf("<text:p text:style-name=\"TOC_Item\"><text:a xlink:type=\"simple\" xlink:href=\"#%s\" text:style-name=\"Index_20_Link\" text:visited-style-name=\"Index_20_Link\">", temp_char);
-                       mmd_export_token_tree_opendocument(out, source, entry->child, scratch);
-                       print_const(" <text:tab/>1</text:a></text:p>\n");
-
-                       if (*counter < scratch->header_stack->size - 1) {
-                               next = stack_peek_index(scratch->header_stack, *counter + 1);
-                               next_level = next->type - BLOCK_H1 + 1;
-
-                               if (next_level > entry_level) {
-                                       // This entry has children
-                                       (*counter)++;
-                                       mmd_export_toc_entry_opendocument(out, source, scratch, counter, entry_level + 1);
+               if (entry_level < min || entry_level > max) {
+                       // Ignore this one
+               } else {
+                       if (entry_level >= level) {
+                               // This entry is a direct descendant of the parent
+                               scratch->label_counter = (int) * counter;
+                               temp_char = label_from_header(source, entry, scratch);
+                               printf("<text:p text:style-name=\"TOC_Item\"><text:a xlink:type=\"simple\" xlink:href=\"#%s\" text:style-name=\"Index_20_Link\" text:visited-style-name=\"Index_20_Link\">", temp_char);
+                               mmd_export_token_tree_opendocument(out, source, entry->child, scratch);
+                               print_const(" <text:tab/>1</text:a></text:p>\n");
+
+                               if (*counter < scratch->header_stack->size - 1) {
+                                       next = stack_peek_index(scratch->header_stack, *counter + 1);
+                                       next_level = next->type - BLOCK_H1 + 1;
+
+                                       if (next_level > entry_level) {
+                                               // This entry has children
+                                               (*counter)++;
+                                               mmd_export_toc_entry_opendocument(out, source, scratch, counter, entry_level + 1, min, max);
+                                       }
                                }
-                       }
 
-                       free(temp_char);
-               } else if (entry_level < level ) {
-                       // If entry < level, exit this level
-                       // Decrement counter first, so that we can test it again later
-                       (*counter)--;
-                       break;
+                               free(temp_char);
+                       } else if (entry_level < level ) {
+                               // If entry < level, exit this level
+                               // Decrement counter first, so that we can test it again later
+                               (*counter)--;
+                               break;
+                       }
                }
 
                // Increment counter
@@ -675,7 +679,7 @@ void mmd_export_toc_entry_opendocument(DString * out, const char * source, scrat
 }
 
 
-void mmd_export_toc_opendocument(DString * out, const char * source, scratch_pad * scratch) {
+void mmd_export_toc_opendocument(DString * out, const char * source, scratch_pad * scratch, short min, short max) {
        size_t counter = 0;
 
        // TODO: Could use LC to internationalize this
@@ -687,7 +691,7 @@ void mmd_export_toc_opendocument(DString * out, const char * source, scratch_pad
        print_const("<text:p text:style-name=\"Contents_20_Heading\">Table of Contents</text:p>\n");
        print_const("</text:index-title>\n");
 
-       mmd_export_toc_entry_opendocument(out, source, scratch, &counter, 0);
+       mmd_export_toc_entry_opendocument(out, source, scratch, &counter, 0, min, max);
 
        print_const("</text:index-body>\n</text:table-of-content>\n\n");
 
@@ -1120,7 +1124,21 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
                case BLOCK_TOC:
                        pad(out, 2, scratch);
 
-                       mmd_export_toc_opendocument(out, source, scratch);
+                       // Define range
+                       if (t->child->child->type == TOC) {
+                               temp_short = 1;
+                               temp_short2 = 6;
+                       } else {
+                               temp_short = source[t->start + 6] - '0';
+
+                               if (t->child->child->type == TOC_RANGE) {
+                                       temp_short2 = source[t->start + 8] - '0';
+                               } else {
+                                       temp_short2 = temp_short;
+                               }
+                       }
+
+                       mmd_export_toc_opendocument(out, source, scratch, temp_short, temp_short2);
 
                        scratch->padded = 1;
                        break;
@@ -2138,6 +2156,8 @@ parse_citation:
                case TEXT_PERIOD:
                case TEXT_PLAIN:
                case TOC:
+               case TOC_SINGLE:
+               case TOC_RANGE:
                case UL:
                        print_token(t);
                        break;
index 5036a3c3ff8ad6eca1799c4bfc297a91f7aa56f1..7d4b25d241446957c9688b2f6fc28856cb0c965a 100644 (file)
@@ -302,6 +302,51 @@ office:mimetype="application/vnd.oasis.opendocument.text">
 </text:table-of-content>
 
 
+<text:table-of-content text:style-name="Sect1" text:protected="true" text:name="Table of Contents1">
+<text:table-of-content-source text:outline-level="10">
+<text:index-title-template text:style-name="Contents_20_Heading">Table of Contents</text:index-title-template>
+</text:table-of-content-source>
+<text:index-body>
+<text:index-title text:style-name="Sect1" text:name="Table of Contents1_Head">
+<text:p text:style-name="Contents_20_Heading">Table of Contents</text:p>
+</text:index-title>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevel" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second Level  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevelb" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second Level b  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevelc" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second Level c  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondleveld" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second level d  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevele" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second level   <text:tab/>1</text:a></text:p>
+</text:index-body>
+</text:table-of-content>
+
+
+<text:table-of-content text:style-name="Sect1" text:protected="true" text:name="Table of Contents1">
+<text:table-of-content-source text:outline-level="10">
+<text:index-title-template text:style-name="Contents_20_Heading">Table of Contents</text:index-title-template>
+</text:table-of-content-source>
+<text:index-body>
+<text:index-title text:style-name="Sect1" text:name="Table of Contents1_Head">
+<text:p text:style-name="Contents_20_Heading">Table of Contents</text:p>
+</text:index-title>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevel" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second Level  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevelb" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second Level b  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#thirdlevel" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Third Level  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevelc" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second Level c  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#thirdlevelb" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Third Level b  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondleveld" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second level d  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#thirdleveld" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Third level d  <text:tab/>1</text:a></text:p>
+<text:p text:style-name="TOC_Item"><text:a xlink:type="simple" xlink:href="#secondlevele" text:style-name="Index_20_Link" text:visited-style-name="Index_20_Link">Second level   <text:tab/>1</text:a></text:p>
+</text:index-body>
+</text:table-of-content>
+
+
+<text:p text:style-name="Standard">foo {{TOC}}</text:p>
+
+<text:p text:style-name="Standard">foo {{TOC:2}}</text:p>
+
+<text:p text:style-name="Standard">foo {{TOC:2-3}}</text:p>
+
+<text:p text:style-name="Preformatted Text">{{TOC}}<text:line-break/><text:line-break/>{{TOC:2}}<text:line-break/><text:line-break/>{{TOC:2-3}}<text:line-break/></text:p>
+
 <text:h text:outline-level="2"><text:bookmark text:name="secondlevel"/>Second Level</text:h>
 
 <text:h text:outline-level="1"><text:bookmark text:name="firstlevel"/>First Level</text:h>
index 4c5cdad69e420dfe13d24c44b72075fb00d62026..d4458c520ecd634efcec3248ee6a551f7ce37fc9 100644 (file)
 </ul>
 </div>
 
+<div class="TOC">
+
+<ul>
+<li><a href="#secondlevel">Second Level </a></li>
+<li><a href="#secondlevelb">Second Level b </a>
+<ul>
+</ul>
+</li>
+<li><a href="#secondlevelc">Second Level c </a></li>
+<li><a href="#secondleveld">Second level d </a>
+<ul>
+</ul>
+</li>
+<li><a href="#secondlevele">Second level  </a></li>
+</ul>
+</div>
+
+<div class="TOC">
+
+<ul>
+<li><a href="#secondlevel">Second Level </a></li>
+<li><a href="#secondlevelb">Second Level b </a>
+<ul>
+<li><a href="#thirdlevel">Third Level </a></li>
+</ul>
+</li>
+<li><a href="#secondlevelc">Second Level c </a></li>
+<li><a href="#thirdlevelb">Third Level b </a></li>
+<li><a href="#secondleveld">Second level d </a>
+<ul>
+<li><a href="#thirdleveld">Third level d </a>
+<ul>
+</ul>
+</li>
+</ul>
+</li>
+<li><a href="#secondlevele">Second level  </a></li>
+</ul>
+</div>
+
+<p>foo {{TOC}}</p>
+
+<p>foo {{TOC:2}}</p>
+
+<p>foo {{TOC:2-3}}</p>
+
+<pre><code>{{TOC}}
+
+{{TOC:2}}
+
+{{TOC:2-3}}
+</code></pre>
+
 <h2 id="secondlevel">Second Level</h2>
 
 <h1 id="firstlevel">First Level</h1>
index da08a61f82cbba79ad2d7bff76b0a847b7e4faea..3b27a855ef1f81c308f1ed25fcf7f80d1feab99f 100644 (file)
@@ -3,6 +3,23 @@ latexconfig:   article</p>
 
 <p>{{TOC}}</p>
 
+<p>{{TOC:2}}</p>
+
+<p>{{TOC:2-3}}</p>
+
+<p>foo {{TOC}}</p>
+
+<p>foo {{TOC:2}}</p>
+
+<p>foo {{TOC:2-3}}</p>
+
+<pre><code>{{TOC}}
+
+{{TOC:2}}
+
+{{TOC:2-3}}
+</code></pre>
+
 <h2>Second Level</h2>
 
 <h1>First Level</h1>
index 984916ea17467a2391249546d58ad6f386c30f6d..372a88c826088d4b82135629193bce4c3be6e691 100644 (file)
@@ -2,7 +2,7 @@
 <opml version="1.0">
 <head><title>Table of Contents</title></head>
 <body>
-<outline text="&gt;&gt;Preamble&lt;&lt;" _note="&#10;{{TOC}}&#10;&#10;"></outline>
+<outline text="&gt;&gt;Preamble&lt;&lt;" _note="&#10;{{TOC}}&#10;&#10;{{TOC:2}}&#10;&#10;{{TOC:2-3}}&#10;&#10;&#10;foo {{TOC}}&#10;&#10;foo {{TOC:2}}&#10;&#10;foo {{TOC:2-3}}&#10;&#10;&#10;&#9;{{TOC}}&#10;&#9;&#10;&#9;{{TOC:2}}&#10;&#9;&#10;&#9;{{TOC:2-3}}&#10;&#10;&#10;&#10;"></outline>
 <outline text="Second Level" _note="&#10;"></outline>
 <outline text="First Level" _note="&#10;"><outline text="Second Level b" _note="&#10;"><outline text="Third Level" _note="&#10;"></outline>
 </outline>
index 05f3fc6c733ac106cc2003e336e6bc65c25d66bc..8e0643284eb787dd669e2c106cdb3b83186d3a9b 100644 (file)
@@ -4,6 +4,26 @@
 
 \tableofcontents
 
+\setcounter{tocdepth}{0}
+\tableofcontents
+
+\setcounter{tocdepth}{1}
+\tableofcontents
+
+foo \{\{TOC\}\}
+
+foo \{\{TOC:2\}\}
+
+foo \{\{TOC:2-3\}\}
+
+\begin{verbatim}
+{{TOC}}
+
+{{TOC:2}}
+
+{{TOC:2-3}}
+\end{verbatim}
+
 \chapter{Second Level}
 \label{secondlevel}
 
index 794698cb661e2db7a03a45bc2581865fb925ecd5..bc7e0fd32655d0f12b8b62c04ee0eecb297e8d1b 100644 (file)
@@ -3,6 +3,26 @@ latexconfig:   article
 
 {{TOC}}
 
+{{TOC:2}}
+
+{{TOC:2-3}}
+
+
+foo {{TOC}}
+
+foo {{TOC:2}}
+
+foo {{TOC:2-3}}
+
+
+       {{TOC}}
+       
+       {{TOC:2}}
+       
+       {{TOC:2-3}}
+
+
+
 ## Second Level ##
 
 # First Level #