rmultimarkdown 6.4.0.4 → 6.7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +7 -13
  3. data/ext/Makefile +67 -55
  4. data/ext/extconf.rb +7 -5
  5. data/ext/mmd/aho-corasick.c +8 -8
  6. data/ext/mmd/aho-corasick.h +3 -3
  7. data/ext/mmd/argtable3.c +6537 -0
  8. data/ext/mmd/argtable3.h +273 -0
  9. data/ext/mmd/beamer.c +12 -1
  10. data/ext/mmd/char.c +120 -27
  11. data/ext/mmd/char.h +23 -23
  12. data/ext/mmd/critic_markup.c +7 -6
  13. data/ext/mmd/d_string.c +88 -32
  14. data/ext/mmd/{include/d_string.h → d_string.h} +50 -38
  15. data/ext/mmd/epub.c +36 -12
  16. data/ext/mmd/epub.h +2 -2
  17. data/ext/mmd/file.c +50 -40
  18. data/ext/mmd/file.h +2 -2
  19. data/ext/mmd/html.c +164 -99
  20. data/ext/mmd/html.h +3 -2
  21. data/ext/mmd/i18n.h +15 -11
  22. data/ext/mmd/itmz-lexer.c +16978 -0
  23. data/ext/mmd/itmz-lexer.h +132 -0
  24. data/ext/mmd/itmz-parser.c +1189 -0
  25. data/ext/mmd/itmz-parser.h +11 -0
  26. data/ext/mmd/itmz-reader.c +388 -0
  27. data/ext/mmd/itmz-reader.h +111 -0
  28. data/ext/mmd/itmz.c +567 -0
  29. data/ext/mmd/itmz.h +117 -0
  30. data/ext/mmd/latex.c +93 -41
  31. data/ext/mmd/lexer.c +3506 -2774
  32. data/ext/mmd/{include/libMultiMarkdown.h → libMultiMarkdown.h} +49 -2
  33. data/ext/mmd/main.c +612 -0
  34. data/ext/mmd/memoir.c +4 -1
  35. data/ext/mmd/miniz.c +6905 -6680
  36. data/ext/mmd/miniz.h +456 -476
  37. data/ext/mmd/mmd.c +399 -94
  38. data/ext/mmd/mmd.h +25 -25
  39. data/ext/mmd/object_pool.h +3 -3
  40. data/ext/mmd/opendocument-content.c +137 -69
  41. data/ext/mmd/opendocument-content.h +2 -2
  42. data/ext/mmd/opendocument.c +35 -14
  43. data/ext/mmd/opendocument.h +2 -2
  44. data/ext/mmd/opml-lexer.c +259 -637
  45. data/ext/mmd/opml-lexer.h +1 -17
  46. data/ext/mmd/opml-parser.c +194 -188
  47. data/ext/mmd/opml-reader.c +72 -142
  48. data/ext/mmd/opml-reader.h +1 -1
  49. data/ext/mmd/opml.c +13 -13
  50. data/ext/mmd/opml.h +1 -1
  51. data/ext/mmd/parser.c +1623 -1244
  52. data/ext/mmd/rng.c +8 -3
  53. data/ext/mmd/scanners.c +66625 -103198
  54. data/ext/mmd/scanners.h +1 -0
  55. data/ext/mmd/stack.c +62 -20
  56. data/ext/mmd/stack.h +10 -21
  57. data/ext/mmd/textbundle.c +23 -7
  58. data/ext/mmd/textbundle.h +2 -2
  59. data/ext/mmd/token.c +42 -16
  60. data/ext/mmd/{include/token.h → token.h} +22 -8
  61. data/ext/mmd/token_pairs.c +0 -16
  62. data/ext/mmd/transclude.c +6 -2
  63. data/ext/mmd/uthash.h +745 -745
  64. data/ext/mmd/version.h +8 -8
  65. data/ext/mmd/writer.c +225 -63
  66. data/ext/mmd/writer.h +50 -36
  67. data/ext/mmd/xml.c +855 -0
  68. data/ext/mmd/xml.h +134 -0
  69. data/ext/mmd/zip.c +71 -4
  70. data/ext/mmd/zip.h +7 -1
  71. data/ext/ruby_multi_markdown.c +9 -18
  72. data/lib/multi_markdown/version.rb +1 -1
  73. data/lib/multi_markdown.bundle +0 -0
  74. data/rmultimarkdown.gemspec +0 -2
  75. metadata +22 -28
  76. data/ext/mmd/char_lookup.c +0 -212
data/ext/mmd/latex.c CHANGED
@@ -62,6 +62,8 @@
62
62
  #include "latex.h"
63
63
  #include "parser.h"
64
64
  #include "scanners.h"
65
+ #include "stack.h"
66
+
65
67
 
66
68
  #define print(x) d_string_append(out, x)
67
69
  #define print_const(x) d_string_append_c_array(out, x, sizeof(x) - 1)
@@ -98,7 +100,7 @@ void mmd_print_char_latex(DString * out, char c) {
98
100
  break;
99
101
 
100
102
  case '/':
101
- print_const("\\slash ");
103
+ print_const("\\slash{}");
102
104
  break;
103
105
 
104
106
  case '^':
@@ -269,16 +271,20 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin
269
271
 
270
272
  if (temp_char && temp_char[0] != '\0') {
271
273
  mmd_export_token_tree_latex(out, source, text->child, scratch);
272
- print_const(" (");
273
- printf("\\autoref{%s}", &(link->url)[1]);
274
- print_const(")");
274
+ print_const(" (\\autoref{");
275
+ mmd_print_string_latex(out, &(link->url)[1]);
276
+ print_const("})");
275
277
  } else {
276
- printf("\\autoref{%s}", &(link->url)[1]);
278
+ print_const("\\autoref{");
279
+ mmd_print_string_latex(out, &(link->url)[1]);
280
+ print_const("}");
277
281
  }
278
282
 
279
283
  free(temp_char);
280
284
  } else {
281
- printf("\\autoref{%s}", &(link->url)[1]);
285
+ print_const("\\autoref{");
286
+ mmd_print_string_latex(out, &(link->url)[1]);
287
+ print_const("}");
282
288
  }
283
289
 
284
290
  return;
@@ -310,8 +316,8 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin
310
316
  }
311
317
 
312
318
 
313
- static char * correct_dimension_units(char *original) {
314
- char *result;
319
+ static char * correct_dimension_units(char * original) {
320
+ char * result;
315
321
  int i;
316
322
 
317
323
  result = my_strdup(original);
@@ -335,11 +341,6 @@ void mmd_export_image_latex(DString * out, const char * source, token * text, li
335
341
  char * width = NULL;
336
342
  float temp_float;
337
343
 
338
- // Compatibility mode doesn't allow figures
339
- if (scratch->extensions & EXT_COMPATIBILITY) {
340
- is_figure = false;
341
- }
342
-
343
344
  if (is_figure) {
344
345
  print_const("\\begin{figure}[htbp]\n\\centering\n");
345
346
  scratch->close_para = false;
@@ -414,8 +415,13 @@ void mmd_export_image_latex(DString * out, const char * source, token * text, li
414
415
  if (is_figure) {
415
416
  print_const("\n");
416
417
 
417
- if (text) {
418
- print_const("\\caption{");
418
+ if ((text && text->len > 3) || (link->title && link->title[0] != '\0')) {
419
+ if (link->title && link->title[0] != '\0') {
420
+ printf("\\caption[%s]{", link->title);
421
+ } else {
422
+ print_const("\\caption{");
423
+ }
424
+
419
425
  mmd_export_token_tree_latex(out, source, text->child, scratch);
420
426
  print_const("}\n");
421
427
  }
@@ -447,7 +453,8 @@ void mmd_export_toc_entry_latex(DString * out, const char * source, scratch_pad
447
453
 
448
454
  if (entry_level >= level) {
449
455
  // This entry is a direct descendant of the parent
450
- temp_char = label_from_header(source, entry);
456
+ scratch->label_counter = (int) * counter;
457
+ temp_char = label_from_header(source, entry, scratch);
451
458
  print_const("\\item ");
452
459
  mmd_export_token_tree_latex(out, source, entry->child, scratch);
453
460
  printf("(\\autoref{%s})\n\n", temp_char);
@@ -482,7 +489,11 @@ void mmd_export_toc_entry_latex(DString * out, const char * source, scratch_pad
482
489
  void mmd_export_toc_latex(DString * out, const char * source, scratch_pad * scratch) {
483
490
  size_t counter = 0;
484
491
 
492
+ int old_label_counter = scratch->label_counter;
493
+
485
494
  mmd_export_toc_entry_latex(out, source, scratch, &counter, 0);
495
+
496
+ scratch->label_counter = old_label_counter;
486
497
  }
487
498
 
488
499
 
@@ -549,6 +560,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
549
560
  // Raw source
550
561
  if (raw_filter_text_matches(temp_char, FORMAT_LATEX)) {
551
562
  switch (t->child->tail->type) {
563
+ case CODE_FENCE_LINE:
552
564
  case LINE_FENCE_BACKTICK_3:
553
565
  case LINE_FENCE_BACKTICK_4:
554
566
  case LINE_FENCE_BACKTICK_5:
@@ -563,7 +575,10 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
563
575
  d_string_append_c_array(out, &source[t->child->next->start], temp_token->start - t->child->next->start);
564
576
  scratch->padded = 1;
565
577
  } else {
566
- d_string_append_c_array(out, &source[t->child->start + t->child->len], t->start + t->len - t->child->next->start);
578
+ if (t->child->next) {
579
+ d_string_append_c_array(out, &source[t->child->start + t->child->len], t->start + t->len - t->child->next->start);
580
+ }
581
+
567
582
  scratch->padded = 0;
568
583
  }
569
584
  }
@@ -634,6 +649,9 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
634
649
  scratch->padded = 1;
635
650
  break;
636
651
 
652
+ case MARKER_DEFLIST_COLON:
653
+ break;
654
+
637
655
  case BLOCK_EMPTY:
638
656
  break;
639
657
 
@@ -690,20 +708,14 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
690
708
  break;
691
709
  }
692
710
 
711
+ header_clean_trailing_whitespace(t->child, source);
693
712
  mmd_export_token_tree_latex(out, source, t->child, scratch);
694
713
  trim_trailing_whitespace_d_string(out);
695
714
 
696
715
  if (scratch->extensions & EXT_NO_LABELS) {
697
716
  print_const("}");
698
717
  } else {
699
- temp_token = manual_label_from_header(t, source);
700
-
701
- if (temp_token) {
702
- temp_char = label_from_token(source, temp_token);
703
- } else {
704
- temp_char = label_from_token(source, t);
705
- }
706
-
718
+ temp_char = label_from_header(source, t, scratch);
707
719
  printf("}\n\\label{%s}", temp_char);
708
720
  free(temp_char);
709
721
  }
@@ -808,6 +820,11 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
808
820
  if (temp_token->next &&
809
821
  temp_token->next->type == PAIR_BRACKET) {
810
822
  temp_token = temp_token->next;
823
+ print_const("\\caption");
824
+ print_token(temp_token);
825
+ print_const("{");
826
+ } else {
827
+ print_const("\\caption{");
811
828
  }
812
829
 
813
830
  temp_char = label_from_token(source, temp_token);
@@ -815,7 +832,6 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
815
832
  t->next->child->child->type = TEXT_EMPTY;
816
833
  t->next->child->child->mate->type = TEXT_EMPTY;
817
834
 
818
- print_const("\\caption{");
819
835
  mmd_export_token_tree_latex(out, source, t->next->child->child, scratch);
820
836
  print_const("}\n");
821
837
 
@@ -894,6 +910,22 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
894
910
 
895
911
  case BLOCK_TOC:
896
912
  pad(out, 2, scratch);
913
+
914
+ // Define range
915
+ if (t->child->child->type == TOC) {
916
+ } else {
917
+ temp_short = source[t->start + 6] - '0';
918
+
919
+ if (t->child->child->type == TOC_RANGE) {
920
+ temp_short2 = source[t->start + 8] - '0';
921
+ } else {
922
+ temp_short2 = temp_short;
923
+ }
924
+
925
+ // Adjust depth for LaTeX numbering -- -1 for part, 0 for chapter
926
+ printf("\\setcounter{tocdepth}{%d}\n", temp_short2 - 2);
927
+ }
928
+
897
929
  print_const("\\tableofcontents");
898
930
  scratch->padded = 0;
899
931
  break;
@@ -1112,6 +1144,8 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
1112
1144
  case MARKER_H4:
1113
1145
  case MARKER_H5:
1114
1146
  case MARKER_H6:
1147
+ case MARKER_SETEXT_1:
1148
+ case MARKER_SETEXT_2:
1115
1149
  case MARKER_LIST_BULLET:
1116
1150
  case MARKER_LIST_ENUMERATOR:
1117
1151
  break;
@@ -1822,7 +1856,7 @@ parse_citation:
1822
1856
  break;
1823
1857
 
1824
1858
  case SLASH:
1825
- print_const("\\slash ");
1859
+ print_const("\\slash{}");
1826
1860
  break;
1827
1861
 
1828
1862
  case STAR:
@@ -1868,20 +1902,24 @@ parse_citation:
1868
1902
  if (t->next->len > 1) {
1869
1903
  printf("\\multicolumn{%lu}{", t->next->len);
1870
1904
 
1871
- switch (scratch->table_alignment[scratch->table_cell_count]) {
1872
- case 'l':
1873
- case 'L':
1874
- print_const("l}{");
1875
- break;
1905
+ if (scratch->table_cell_count < kMaxTableColumns) {
1906
+ switch (scratch->table_alignment[scratch->table_cell_count]) {
1907
+ case 'l':
1908
+ case 'L':
1909
+ print_const("l}{");
1910
+ break;
1876
1911
 
1877
- case 'r':
1878
- case 'R':
1879
- print_const("r}{");
1880
- break;
1912
+ case 'r':
1913
+ case 'R':
1914
+ print_const("r}{");
1915
+ break;
1881
1916
 
1882
- default:
1883
- print_const("c}{");
1884
- break;
1917
+ default:
1918
+ print_const("c}{");
1919
+ break;
1920
+ }
1921
+ } else {
1922
+ print_const("l}{");
1885
1923
  }
1886
1924
  }
1887
1925
  }
@@ -1962,10 +2000,24 @@ parse_citation:
1962
2000
  print_const("\\{\\{TOC\\}\\}");
1963
2001
  break;
1964
2002
 
2003
+ case TOC_SINGLE:
2004
+ temp_short = source[t->start + 6] - '0';
2005
+ printf("\\{\\{TOC:%d\\}\\}", temp_short);
2006
+ break;
2007
+
2008
+ case TOC_RANGE:
2009
+ temp_short = source[t->start + 6] - '0';
2010
+ temp_short2 = source[t->start + 8] - '0';
2011
+ printf("\\{\\{TOC:%d-%d\\}\\}", temp_short, temp_short2);
2012
+ break;
2013
+
1965
2014
  case UL:
1966
2015
  print_const("\\_");
1967
2016
  break;
1968
2017
 
2018
+ case OBJECT_REPLACEMENT_CHARACTER:
2019
+ break;
2020
+
1969
2021
  default:
1970
2022
  fprintf(stderr, "Unknown token type: %d\n", t->type);
1971
2023
  token_describe(t, source);
@@ -2236,7 +2288,7 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
2236
2288
  break;
2237
2289
 
2238
2290
  case SLASH:
2239
- print_const("\\slash ");
2291
+ print_const("\\slash{}");
2240
2292
  break;
2241
2293
 
2242
2294
  case TEXT_BACKSLASH:
@@ -2425,7 +2477,7 @@ void mmd_start_complete_latex(DString * out, const char * source, scratch_pad *
2425
2477
  print_const("}\n");
2426
2478
  } else if (strcmp(m->key, "bibtex") == 0) {
2427
2479
  print_const("\\def\\bibliocommand{\\bibliography{");
2428
- mmd_print_string_latex(out, m->value);
2480
+ print(m->value);
2429
2481
  print_const("}}\n");
2430
2482
  } else if (strcmp(m->key, "transcludebase") == 0) {
2431
2483
  } else if (strcmp(m->key, "xhtmlheader") == 0) {