}
-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;
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
}
-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;
}
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;
case TEXT_PERIOD:
case TEXT_PLAIN:
case TOC:
+ case TOC_SINGLE:
+ case TOC_RANGE:
print_token(t);
break;
TABLE_DIVIDER,
TOC,
+ TOC_SINGLE,
+ TOC_RANGE,
TEXT_BACKSLASH,
RAW_FILTER_LEFT,
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;
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;
-/* 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.
yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case ' ': goto yy328;
+ case ' ': goto yy338;
default: goto yy7;
}
yy7:
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:
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;
yy10:
yych = *++YYCURSOR;
switch (yych) {
- case '[': goto yy323;
+ case '[': goto yy333;
default: goto yy3;
}
yy11:
case '\n':
case '\r':
case ' ':
- case 0xC2: goto yy278;
- case '#': goto yy276;
+ case 0xC2: goto yy288;
+ case '#': goto yy286;
default: goto yy14;
}
yy14:
yy15:
++YYCURSOR;
switch ((yych = *YYCURSOR)) {
- case '$': goto yy274;
+ case '$': goto yy284;
default: goto yy16;
}
yy16:
yyaccept = 3;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case '#': goto yy258;
+ case '#': goto yy268;
case '0':
case '1':
case '2':
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:
yy21:
++YYCURSOR;
switch ((yych = *YYCURSOR)) {
- case '\'': goto yy253;
+ case '\'': goto yy263;
default: goto yy22;
}
yy22:
yyaccept = 4;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case '+': goto yy250;
+ case '+': goto yy260;
default: goto yy30;
}
yy30:
yy31:
++YYCURSOR;
switch ((yych = *YYCURSOR)) {
- case '-': goto yy242;
+ case '-': goto yy252;
default: goto yy32;
}
yy32:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case ' ': goto yy234;
- case '.': goto yy235;
+ case ' ': goto yy244;
+ case '.': goto yy245;
default: goto yy3;
}
yy34:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case '.': goto yy225;
+ case '.': goto yy235;
case '0':
case '1':
case '2':
case '6':
case '7':
case '8':
- case '9': goto yy226;
+ case '9': goto yy236;
default: goto yy3;
}
yy37:
yyaccept = 5;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case '!': goto yy218;
- case '<': goto yy219;
+ case '!': goto yy228;
+ case '<': goto yy229;
default: goto yy40;
}
yy40:
yyaccept = 6;
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
- case '=': goto yy215;
+ case '=': goto yy225;
default: goto yy42;
}
yy42:
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:
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:
yy55:
++YYCURSOR;
yych = *YYCURSOR;
- goto yy127;
+ goto yy137;
yy56:
{ return BACKTICK; }
yy57:
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;
yy102:
++YYCURSOR;
switch ((yych = *YYCURSOR)) {
- case '=': goto yy124;
+ case '=': goto yy134;
default: goto yy103;
}
yy103:
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;
{ 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':
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':
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':
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) {
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':
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) {
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) {
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) {
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) {
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) {
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) {
case '|':
case '}':
case '~':
- case 0x7F: goto yy329;
+ case 0x7F: goto yy339;
case 0xC2:
case 0xC3:
case 0xC4:
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:
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:
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:
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:
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:
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:
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:
case 0x8C:
case 0x8D:
case 0x8E:
- case 0x8F: goto yy333;
+ case 0x8F: goto yy343;
default: goto yy67;
}
}
"{{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; }
line->type = LINE_EMPTY;
break;
+ case TOC_SINGLE:
+ case TOC_RANGE:
case TOC:
line->type = (e->extensions & EXT_COMPATIBILITY) ? LINE_PLAIN : LINE_TOC;
break;
}
-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;
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
}
-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
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");
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;
case TEXT_PERIOD:
case TEXT_PLAIN:
case TOC:
+ case TOC_SINGLE:
+ case TOC_RANGE:
case UL:
print_token(t);
break;
</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>
</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>
<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>
<opml version="1.0">
<head><title>Table of Contents</title></head>
<body>
-<outline text=">>Preamble<<" _note=" {{TOC}} "></outline>
+<outline text=">>Preamble<<" _note=" {{TOC}} {{TOC:2}} {{TOC:2-3}} foo {{TOC}} foo {{TOC:2}} foo {{TOC:2-3}} 	{{TOC}} 	 	{{TOC:2}} 	 	{{TOC:2-3}} "></outline>
<outline text="Second Level" _note=" "></outline>
<outline text="First Level" _note=" "><outline text="Second Level b" _note=" "><outline text="Third Level" _note=" "></outline>
</outline>
\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}
{{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 #