rmultimarkdown 4.5.3.2 → 4.6.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d175433e6b773f208302634ae4a98fd19843a33a
4
- data.tar.gz: 6196eef19a7bb5802a4a60b757557d83983cf6a8
3
+ metadata.gz: d09abf7122bde215cae33570b460aa1d63874cfc
4
+ data.tar.gz: a9cf6ae5f6f8738f471266cd9594285dc32c32a8
5
5
  SHA512:
6
- metadata.gz: 94a12726d7a0e62191317902b33ae7076e1157c10176a3cba4e838c384ff00ee40e069d069dd505bd98f630a1b2474565c4ad3017816f4c90a461958146bdbf0
7
- data.tar.gz: 18d9054243c74d3dafa979e77539cb587b9dddd554fe734d8d23fa578ba870be7ebe6940f79657163613cdeb5d724916a06fdda5cff7badba99e613249bc2410
6
+ metadata.gz: feba15b48f3fe5ba7340d3c2037b48ebb44d8f1ba82a125216018e646081cf4ce5dd2d67c23c2acc00d8bf3f4854cb2335ea9f885f63d4368221aa9f550dd192
7
+ data.tar.gz: 0f47cae9ff4087bd5ca8c1780a8aafcdc0b378e71387e580fa892708633f743cc571c66bea40444a447af172604e1495c6b632791a6c4cb9aa7b657dcbaabf1c
@@ -124,6 +124,8 @@ void print_beamer_node(GString *out, node *n, scratch_pad *scratch) {
124
124
  /* print_beamer_endnotes */
125
125
  void print_beamer_endnotes(GString *out, scratch_pad *scratch) {
126
126
  scratch->used_notes = reverse_list(scratch->used_notes);
127
+ scratch->printing_notes = 1;
128
+
127
129
  node *note = scratch->used_notes;
128
130
  #ifdef DEBUG_ON
129
131
  fprintf(stderr, "start endnotes\n");
@@ -68,8 +68,34 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
68
68
  print_html_node_tree(out,n->children,scratch);
69
69
  break;
70
70
  case STR:
71
+ /* fprintf(stderr, "str: '%s'\n", n->str); */
71
72
  print_html_string(out,n->str, scratch);
72
73
  break;
74
+ case ABBR:
75
+ if (strlen(n->children->str) == 0) {
76
+ g_string_append_printf(out, "<abbr>");
77
+ } else {
78
+ g_string_append_printf(out, "<abbr title=\"");
79
+ print_html_string(out, n->children->str, scratch);
80
+ g_string_append_printf(out, "\">");
81
+ }
82
+ print_html_string(out,n->str, scratch);
83
+ g_string_append_printf(out, "</abbr>");
84
+ break;
85
+ case ABBRSTART:
86
+ if (strlen(n->children->str) == 0) {
87
+ g_string_append_printf(out, "<abbr>");
88
+ } else {
89
+ g_string_append_printf(out, "<abbr title=\"");
90
+ print_html_string(out, n->children->str, scratch);
91
+ g_string_append_printf(out, "\">");
92
+ }
93
+ print_html_string(out,n->str, scratch);
94
+ break;
95
+ case ABBRSTOP:
96
+ print_html_string(out,n->str, scratch);
97
+ g_string_append_printf(out, "</abbr>");
98
+ break;
73
99
  case SPACE:
74
100
  g_string_append_printf(out,"%s",n->str);
75
101
  break;
@@ -110,6 +136,7 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
110
136
  scratch->padded = 0;
111
137
  break;
112
138
  case VERBATIM:
139
+ case VERBATIMFENCE:
113
140
  pad(out, 2, scratch);
114
141
  if ((n->children != NULL) && (n->children->key == VERBATIMTYPE)) {
115
142
  trim_trailing_whitespace(n->children->str);
@@ -217,6 +244,7 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
217
244
  trim_trailing_whitespace(n->children->str);
218
245
  print_raw_node(out, n->children);
219
246
  g_string_append_printf(out, "\n");
247
+ } else if (strcmp(n->str, "mmdfooter") == 0) {
220
248
  } else {
221
249
  g_string_append_printf(out,"\t<meta name=\"%s\" content=\"",n->str);
222
250
  print_html_node(out,n->children,scratch);
@@ -287,21 +315,23 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
287
315
  g_string_append_printf(out, "<br/>\n");
288
316
  break;
289
317
  case MATHSPAN:
290
- if (n->str[0] == '$') {
291
- n->str[strlen(n->str)-1] = '\0';
292
- if (n->str[1] == '$') {
293
- n->str[strlen(n->str)-1] = '\0';
294
- g_string_append_printf(out, "<span class=\"math\">\\[%s\\]</span>",&n->str[2]);
318
+ temp = strdup(n->str);
319
+ if (temp[0] == '$') {
320
+ temp[strlen(temp)-1] = '\0';
321
+ if (temp[1] == '$') {
322
+ temp[strlen(temp)-1] = '\0';
323
+ g_string_append_printf(out, "<span class=\"math\">\\[%s\\]</span>",&temp[2]);
295
324
  } else {
296
- g_string_append_printf(out, "<span class=\"math\">\\(%s\\)</span>",&n->str[1]);
325
+ g_string_append_printf(out, "<span class=\"math\">\\(%s\\)</span>",&temp[1]);
297
326
  }
298
- } else if (n->str[strlen(n->str) - 1] == ']') {
299
- n->str[strlen(n->str) - 3] = '\0';
300
- g_string_append_printf(out, "<span class=\"math\">%s\\]</span>",n->str);
327
+ } else if (temp[strlen(temp) - 1] == ']') {
328
+ temp[strlen(temp) - 3] = '\0';
329
+ g_string_append_printf(out, "<span class=\"math\">%s\\]</span>",temp);
301
330
  } else {
302
- n->str[strlen(n->str) - 3] = '\0';
303
- g_string_append_printf(out, "<span class=\"math\">%s\\)</span>",n->str);
331
+ temp[strlen(temp) - 3] = '\0';
332
+ g_string_append_printf(out, "<span class=\"math\">%s\\)</span>",temp);
304
333
  }
334
+ free(temp);
305
335
  break;
306
336
  case STRONG:
307
337
  g_string_append_printf(out, "<strong>");
@@ -410,6 +440,12 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
410
440
  #ifdef DEBUG_ON
411
441
  fprintf(stderr, "print image\n");
412
442
  #endif
443
+ /* Verify all is well */
444
+ if (n->link_data == NULL) {
445
+ fprintf(stderr, "Invalid IMAGEBLOCK or IMAGE -- (null) link_data\n");
446
+ exit(EXIT_FAILURE);
447
+ }
448
+
413
449
  /* Stash a copy of the link data */
414
450
  if (n->link_data != NULL)
415
451
  temp_link_data = mk_link_data(n->link_data->label, n->link_data->source, n->link_data->title, n->link_data->attr);
@@ -510,10 +546,15 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
510
546
  }
511
547
  g_string_append_printf(out, " />");
512
548
  if (n->key == IMAGEBLOCK) {
513
- if ((n->children != NULL) && (n->children->children != NULL) && (n->children->children->str != NULL)) {
514
- g_string_append_printf(out, "\n<figcaption>");
515
- print_html_node(out,n->children,scratch);
516
- g_string_append_printf(out, "</figcaption>");
549
+ if (n->children != NULL) {
550
+ temp_str = g_string_new("");
551
+ print_html_node(temp_str,n->children,scratch);
552
+ if (temp_str->currentStringLength > 0) {
553
+ g_string_append_printf(out, "\n<figcaption>");
554
+ g_string_append(out, temp_str->str);
555
+ g_string_append_printf(out, "</figcaption>");
556
+ }
557
+ g_string_free(temp_str, true);
517
558
  }
518
559
  g_string_append_printf(out,"\n</figure>");
519
560
  scratch->padded = 0;
@@ -715,6 +756,7 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
715
756
  g_string_append_printf(out, "</table>\n");
716
757
  scratch->cell_type = 0;
717
758
  scratch->padded = 1;
759
+ scratch->table_alignment = NULL;
718
760
  break;
719
761
  case TABLESEPARATOR:
720
762
  scratch->table_alignment = n->str;
@@ -801,6 +843,7 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
801
843
  fprintf(stderr,"SOURCEBRANCH\n");
802
844
  break;
803
845
  case NOTELABEL:
846
+ case GLOSSARYLABEL:
804
847
  break;
805
848
  case SUPERSCRIPT:
806
849
  g_string_append_printf(out, "<sup>%s</sup>",n->str);
@@ -808,6 +851,7 @@ void print_html_node(GString *out, node *n, scratch_pad *scratch) {
808
851
  case SUBSCRIPT:
809
852
  g_string_append_printf(out, "<sub>%s</sub>",n->str);
810
853
  break;
854
+ case ABBREVIATION:
811
855
  case KEY_COUNTER:
812
856
  break;
813
857
  default:
@@ -96,6 +96,42 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
96
96
  case STR:
97
97
  print_latex_string(out,n->str, scratch);
98
98
  break;
99
+ case ABBREVIATION:
100
+ /* We combine the short and full names, since stripping non-ascii characters may result
101
+ in a conflict otherwise. This at least makes it less likely. */
102
+ width = ascii_label_from_node(n->children);
103
+ temp = ascii_label_from_string(n->str);
104
+ g_string_append_printf(out, "\\newacro{%s%s}[",width,temp);
105
+ print_latex_node_tree(out, n->children, scratch);
106
+ g_string_append_printf(out, "]{");
107
+ trim_trailing_whitespace(n->str);
108
+ print_latex_string(out, n->str, scratch);
109
+ g_string_append_printf(out, "}\n");
110
+ free(temp);
111
+ free(width);
112
+ break;
113
+ case ABBRSTART:
114
+ /* Strip out nodes that are being replaced with the abbreviation */
115
+ temp_node = n->next;
116
+ while (temp_node->key != ABBRSTOP) {
117
+ n->next = temp_node->next;
118
+ temp_node->next = NULL;
119
+ free_node(temp_node);
120
+ temp_node = n->next;
121
+ }
122
+ n->next = temp_node->next;
123
+ temp_node->next = NULL;
124
+ free_node(temp_node);
125
+ case ABBR:
126
+ /* In either case, now we call on the abbreviation */
127
+ width = ascii_label_from_node(n->children->children);
128
+ temp = ascii_label_from_string(n->children->str);
129
+ g_string_append_printf(out, "\\ac{%s%s}", width, temp);
130
+ free(temp);
131
+ free(width);
132
+ break;
133
+ case ABBRSTOP:
134
+ break;
99
135
  case SPACE:
100
136
  g_string_append_printf(out,"%s",n->str);
101
137
  break;
@@ -126,6 +162,7 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
126
162
  }
127
163
  break;
128
164
  case VERBATIM:
165
+ case VERBATIMFENCE:
129
166
  pad(out, 2, scratch);
130
167
  if ((n->children != NULL) && (n->children->key == VERBATIMTYPE)) {
131
168
  trim_trailing_whitespace(n->children->str);
@@ -170,6 +207,8 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
170
207
  if (!(scratch->extensions & EXT_SNIPPET) && (is_latex_complete_doc(n))) {
171
208
  scratch->extensions = scratch->extensions | EXT_COMPLETE;
172
209
  }
210
+ /* print acronym definitions */
211
+ print_latex_node_tree(out, scratch->abbreviations, scratch);
173
212
  break;
174
213
  case METAKEY:
175
214
  /* reformat the key */
@@ -221,6 +260,7 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
221
260
  } else if (strcmp(n->str, "css") == 0) {
222
261
  } else if (strcmp(n->str, "xhtmlheader") == 0) {
223
262
  } else if (strcmp(n->str, "htmlheader") == 0) {
263
+ } else if (strcmp(n->str, "mmdfooter") == 0) {
224
264
  } else if (strcmp(n->str, "latexinput") == 0) {
225
265
  trim_trailing_whitespace(n->children->str);
226
266
  g_string_append_printf(out, "\\input{%s}\n", n->children->str);
@@ -327,35 +367,37 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
327
367
  g_string_append_printf(out, "\\\\\n");
328
368
  break;
329
369
  case MATHSPAN:
330
- if (n->str[0] == '$') {
331
- if (n->str[1] == '$') {
332
- if (strncmp(&n->str[2],"\\begin",5) == 0) {
333
- n->str[strlen(n->str)-2] = '\0';
334
- g_string_append_printf(out, "%s",&n->str[1]);
370
+ temp = strdup(n->str);
371
+ if (temp[0] == '$') {
372
+ if (temp[1] == '$') {
373
+ if (strncmp(&temp[2],"\\begin",5) == 0) {
374
+ temp[strlen(temp)-2] = '\0';
375
+ g_string_append_printf(out, "%s",&temp[1]);
335
376
  } else {
336
- g_string_append_printf(out, "%s",n->str);
377
+ g_string_append_printf(out, "%s",temp);
337
378
  }
338
379
  } else {
339
- if (strncmp(&n->str[1],"\\begin",5) == 0) {
340
- n->str[strlen(n->str)-1] = '\0';
341
- g_string_append_printf(out, "%s",&n->str[1]);
380
+ if (strncmp(&temp[1],"\\begin",5) == 0) {
381
+ temp[strlen(temp)-1] = '\0';
382
+ g_string_append_printf(out, "%s",&temp[1]);
342
383
  } else {
343
- g_string_append_printf(out, "%s",n->str);
384
+ g_string_append_printf(out, "%s",temp);
344
385
  }
345
386
  }
346
- } else if (strncmp(&n->str[2],"\\begin",5) == 0) {
387
+ } else if (strncmp(&temp[2],"\\begin",5) == 0) {
347
388
  /* trim */
348
- n->str[strlen(n->str)-3] = '\0';
349
- g_string_append_printf(out, "%s", &n->str[2]);
389
+ temp[strlen(temp)-3] = '\0';
390
+ g_string_append_printf(out, "%s", &temp[2]);
350
391
  } else {
351
- if (n->str[strlen(n->str)-1] == ']') {
352
- n->str[strlen(n->str)-3] = '\0';
353
- g_string_append_printf(out, "%s\\]", n->str);
392
+ if (temp[strlen(temp)-1] == ']') {
393
+ temp[strlen(temp)-3] = '\0';
394
+ g_string_append_printf(out, "%s\\]", temp);
354
395
  } else {
355
- n->str[strlen(n->str)-3] = '\0';
356
- g_string_append_printf(out, "$%s$", &n->str[2]);
396
+ temp[strlen(temp)-3] = '\0';
397
+ g_string_append_printf(out, "$%s$", &temp[2]);
357
398
  }
358
399
  }
400
+ free(temp);
359
401
  break;
360
402
  case STRONG:
361
403
  g_string_append_printf(out, "\\textbf{");
@@ -583,10 +625,16 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
583
625
 
584
626
  if (n->key == IMAGEBLOCK) {
585
627
  if (n->children != NULL) {
586
- g_string_append_printf(out, "\n\\caption{");
587
- print_latex_node_tree(out, n->children, scratch);
588
- g_string_append_printf(out, "}");
628
+ temp_str = g_string_new("");
629
+ print_latex_node_tree(temp_str,n->children,scratch);
630
+ if (temp_str->currentStringLength > 0) {
631
+ g_string_append_printf(out, "\n\\caption{");
632
+ g_string_append(out, temp_str->str);
633
+ g_string_append_printf(out, "}");
634
+ }
635
+ g_string_free(temp_str, true);
589
636
  }
637
+
590
638
  if (n->link_data->label != NULL) {
591
639
  temp = label_from_string(n->link_data->label);
592
640
  g_string_append_printf(out, "\n\\label{%s}",temp);
@@ -788,7 +836,12 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
788
836
  g_string_append_printf(temp_str,"%c",toupper(n->str[i]));
789
837
  }
790
838
  g_string_append_printf(out, "\\begin{tabulary}{\\textwidth}{@{}%s@{}} \\toprule\n", temp_str->str);
791
- g_string_free(temp_str, true);
839
+
840
+ if (scratch->table_alignment != NULL)
841
+ free(scratch->table_alignment);
842
+
843
+ scratch->table_alignment = temp_str->str;
844
+ g_string_free(temp_str, false);
792
845
  break;
793
846
  case TABLECAPTION:
794
847
  if ((n->children != NULL) && (n->children->key == TABLELABEL)) {
@@ -818,11 +871,14 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
818
871
  case TABLEROW:
819
872
  print_latex_node_tree(out, n->children, scratch);
820
873
  g_string_append_printf(out, "\\\\\n");
874
+ scratch->table_column = 0;
821
875
  break;
822
876
  case TABLECELL:
823
877
  scratch->padded = 2;
878
+ temp = scratch->table_alignment;
824
879
  if ((n->children != NULL) && (n->children->key == CELLSPAN)) {
825
- g_string_append_printf(out, "\\multicolumn{%d}{c}{",(int)strlen(n->children->str)+1);
880
+ g_string_append_printf(out, "\\multicolumn{%d}{%c}{",
881
+ (int)strlen(n->children->str)+1,tolower(temp[scratch->table_column]));
826
882
  }
827
883
  print_latex_node_tree(out, n->children, scratch);
828
884
  if ((n->children != NULL) && (n->children->key == CELLSPAN)) {
@@ -830,6 +886,10 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
830
886
  }
831
887
  if (n->next != NULL)
832
888
  g_string_append_printf(out, "&");
889
+ if ((n->children != NULL) && (n->children->key == CELLSPAN)) {
890
+ scratch->table_column += (int)strlen(n->children->str);
891
+ }
892
+ scratch->table_column++;
833
893
  break;
834
894
  case CELLSPAN:
835
895
  break;
@@ -846,6 +906,7 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
846
906
  fprintf(stderr,"SOURCEBRANCH\n");
847
907
  break;
848
908
  case NOTELABEL:
909
+ case GLOSSARYLABEL:
849
910
  break;
850
911
  case SUPERSCRIPT:
851
912
  g_string_append_printf(out, "\\textsuperscript{%s}",n->str);
@@ -1099,7 +1160,14 @@ void print_latex_string(GString *out, char *str, scratch_pad *scratch) {
1099
1160
  }
1100
1161
  break;
1101
1162
  case '-':
1102
- g_string_append_printf(out, "-{}");
1163
+ str++;
1164
+ if (*str == '-') {
1165
+ g_string_append_printf(out, "-{}");
1166
+ str--;
1167
+ } else {
1168
+ str--;
1169
+ g_string_append_c(out,*str);
1170
+ }
1103
1171
  break;
1104
1172
  default:
1105
1173
  g_string_append_c(out, *str);
@@ -105,6 +105,7 @@ enum keys {
105
105
  RAW,
106
106
  VERBATIM,
107
107
  VERBATIMTYPE,
108
+ VERBATIMFENCE,
108
109
  DEFLIST,
109
110
  TERM,
110
111
  DEFINITION,
@@ -127,6 +128,7 @@ enum keys {
127
128
  CITATIONSOURCE,
128
129
  SOURCEBRANCH,
129
130
  NOTELABEL,
131
+ GLOSSARYLABEL,
130
132
  ATTRVALUE,
131
133
  ATTRKEY,
132
134
  GLOSSARYSOURCE,
@@ -142,9 +144,14 @@ enum keys {
142
144
  SUPERSCRIPT,
143
145
  SUBSCRIPT,
144
146
  VARIABLE,
147
+ ABBREVIATION,
148
+ ABBR,
149
+ ABBRSTART,
150
+ ABBRSTOP,
145
151
  KEY_COUNTER /* This *MUST* be the last item in the list */
146
152
  };
147
153
 
154
+
148
155
  /* This is the element used in the resulting parse tree */
149
156
  struct node {
150
157
  short key; /* what type of element are we? */
@@ -155,3 +162,14 @@ struct node {
155
162
  };
156
163
 
157
164
  typedef struct node node;
165
+
166
+
167
+ /* Define a structure to simplify handling of links */
168
+ struct link_data {
169
+ char *label; /* if this is a reference link */
170
+ char *source; /* source URL */
171
+ char *title; /* title string */
172
+ node *attr; /* attribute tree */
173
+ };
174
+
175
+ typedef struct link_data link_data;
@@ -31,6 +31,7 @@
31
31
  /* allow the user to change the heading levels */
32
32
 
33
33
  GString *heading_name[7];
34
+ GString *used_abbreviations;
34
35
 
35
36
  #if defined(DEBUG_ON) || defined(DUMP_TREES)
36
37
  const char * const node_types[] = {
@@ -99,6 +100,7 @@ GString *heading_name[7];
99
100
  "CITATIONSOURCE",
100
101
  "SOURCEBRANCH",
101
102
  "NOTELABEL",
103
+ "GLOSSARYLABEL",
102
104
  "ATTRVALUE",
103
105
  "ATTRKEY",
104
106
  "GLOSSARYSOURCE",
@@ -113,6 +115,11 @@ GString *heading_name[7];
113
115
  "CRITICCOMMENT",
114
116
  "SUPERSCRIPT",
115
117
  "SUBSCRIPT",
118
+ "VARIABLE",
119
+ "ABBREVIATION",
120
+ "ABBR",
121
+ "ABBRSTART",
122
+ "ABBRSTOP",
116
123
  "KEY_COUNTER"
117
124
  };
118
125
 
@@ -154,6 +161,7 @@ void perform_lyx_output(GString *out, node* list, scratch_pad *scratch)
154
161
  node *headings;
155
162
  node *base_header_level;
156
163
  char *key;
164
+
157
165
 
158
166
  #ifdef DUMP_TREES
159
167
  fprintf(stderr, "\n*** Base Tree ***\n");
@@ -179,6 +187,7 @@ void perform_lyx_output(GString *out, node* list, scratch_pad *scratch)
179
187
  affect creating the prefixes */
180
188
 
181
189
  GString *lyx_headings = g_string_new("");
190
+ used_abbreviations = g_string_new("");
182
191
  int hcount;
183
192
  hcount = 0;
184
193
  const char s[2] = ",";
@@ -240,7 +249,7 @@ void perform_lyx_output(GString *out, node* list, scratch_pad *scratch)
240
249
  for (i=0;i<=6;i++){
241
250
  g_string_free(heading_name[i],TRUE);
242
251
  }
243
-
252
+ g_string_free(used_abbreviations,TRUE);
244
253
  }
245
254
 
246
255
  /* begin_lyx_output -- Check metadata and open the document */
@@ -464,9 +473,6 @@ bool begin_lyx_output(GString *out, node* list, scratch_pad *scratch) {
464
473
  free(tmp);
465
474
  free(token);
466
475
  }
467
- }
468
- if(isbeamer){
469
- g_string_append(out,"beamer-fragile\n");
470
476
  }
471
477
  g_string_append(out,"\\end_modules\n");
472
478
 
@@ -560,7 +566,7 @@ void end_lyx_output(GString *out, node* list, scratch_pad *scratch) {
560
566
  if (tree_contains_key(list, METAKEY)) {
561
567
  content = metadata_for_key("bibtex",list);
562
568
  if (content != NULL) {
563
- g_string_append(out, "\n\\begin_layout Standart\n");
569
+ g_string_append(out, "\n\\begin_layout Standard\n");
564
570
  g_string_append(out,"\n\\begin_inset CommandInset bibtex");
565
571
  g_string_append(out,"\nLatexCommand bibtex");
566
572
  value = metavalue_for_key("bibtex",list);
@@ -645,6 +651,56 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
645
651
  case STR:
646
652
  print_lyx_string(out,n->str, scratch,LYX_NONE);
647
653
  break;
654
+ case ABBREVIATION:
655
+ // this work was done in writer.c
656
+ break;
657
+ case ABBRSTART:
658
+ /* Strip out nodes that are being replaced with the abbreviation */
659
+ temp_node = n->next;
660
+ while (temp_node->key != ABBRSTOP) {
661
+ n->next = temp_node->next;
662
+ temp_node->next = NULL;
663
+ free_node(temp_node);
664
+ temp_node = n->next;
665
+ }
666
+ n->next = temp_node->next;
667
+ temp_node->next = NULL;
668
+ free_node(temp_node);
669
+ case ABBR:
670
+ /* In either case, now we call on the abbreviation */
671
+ // width = ascii_label_from_node(n->children->children);
672
+ width = string_from_node_tree(n->children->children);
673
+ // temp = ascii_label_from_string(n->children->str);
674
+ temp_str = g_string_new("");
675
+ g_string_append_printf(temp_str,"[%s]",width);
676
+ if(strstr(used_abbreviations->str,temp_str->str)){
677
+ g_string_append(out,width); // just the abbrev
678
+ }
679
+ else
680
+ {
681
+ g_string_append(used_abbreviations,temp_str->str);
682
+
683
+
684
+ g_string_append(out,n->children->str);
685
+ g_string_append_printf(out," (%s)",width);
686
+
687
+
688
+ g_string_append(out,"\n\\begin_inset CommandInset nomenclature");
689
+ g_string_append(out,"\nLatexCommand nomenclature");
690
+ g_string_append_printf(out,"\nsymbol \"%s\"",width);
691
+ g_string_append(out,"\ndescription \"");
692
+ // g_string_append(out,n->children->str);
693
+ temp = escape_string(n->children->str);
694
+ g_string_append(out,temp);
695
+ g_string_append(out,"\"");
696
+ g_string_append(out, "\n\\end_inset\n");
697
+ free(temp);
698
+ }
699
+ g_string_free(temp_str,TRUE);
700
+ free(width);
701
+ break;
702
+ case ABBRSTOP:
703
+ break;
648
704
  case SPACE:
649
705
  if (strncmp(n->str,"\n",1)==0){
650
706
  if (no_newline){
@@ -684,16 +740,26 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
684
740
  break;
685
741
  case ORDEREDLIST:
686
742
  g_string_append(out, "\n\\begin_layout Enumerate\n");
743
+ if (scratch-> lyx_beamerbullet){
744
+ g_string_append(out,"\n\\begin_inset Argument 1");
745
+ g_string_append(out,"\nstatus open\n");
746
+ g_string_append(out,"\n\\begin_layout Plain Layout");
747
+ g_string_append(out,"\n<+->");
748
+ g_string_append(out,"\n\\end_layout\n");
749
+ g_string_append(out,"\n\\end_inset\n");
750
+ scratch -> lyx_beamerbullet = FALSE;
751
+ }
687
752
  break;
688
753
  case BULLETLIST:
689
754
  g_string_append(out, "\n\\begin_layout Itemize\n");
690
755
  if (scratch-> lyx_beamerbullet){
691
- g_string_append(out,"\n\\begin_inset ERT");
692
- g_string_append(out,"\nstatus collapsed\n");
756
+ g_string_append(out,"\n\\begin_inset Argument 1");
757
+ g_string_append(out,"\nstatus open\n");
693
758
  g_string_append(out,"\n\\begin_layout Plain Layout");
694
- g_string_append(out,"\n<+->");
759
+ g_string_append(out,"\n+-");
695
760
  g_string_append(out,"\n\\end_layout\n");
696
761
  g_string_append(out,"\n\\end_inset\n");
762
+ scratch -> lyx_beamerbullet = FALSE;
697
763
  }
698
764
  break;
699
765
  case NOTEREFERENCE:
@@ -742,12 +808,13 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
742
808
  if (strncmp(n->str,"<!--",4) == 0) {
743
809
  /* trim "-->" from end */
744
810
  n->str[strlen(n->str)-3] = '\0';
745
- g_string_append(out, "\n\\begin_layout Plain\n\\begin_inset ERT\nstatus collapsed\n\n\\begin_layout Plain Layout\n\n");
811
+ g_string_append(out, "\n\\begin_layout Plain Layout\n\\begin_inset ERT\nstatus collapsed\n\n\\begin_layout Plain Layout\n\n");
746
812
  print_latex_string(out,&n->str[4],scratch);
747
- g_string_append(out,"\n\n\\end_layout\n\\end_inset\n\\end_layout\n");
813
+ g_string_append(out,"\n\n\\end_layout\n\n\\end_inset\n\\end_layout\n");
748
814
  }
749
815
  break;
750
816
  case VERBATIM:
817
+ case VERBATIMFENCE:
751
818
  old_type = scratch->lyx_para_type;
752
819
  scratch->lyx_para_type = VERBATIM;
753
820
  scratch->lyx_level++;
@@ -804,7 +871,6 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
804
871
  #ifdef DEBUG_ON
805
872
  fprintf(stderr, "\nStart List Item\n");
806
873
  #endif
807
- i = 0;
808
874
  old_type = scratch->lyx_para_type;
809
875
  temp_node = n-> children; /* should be a list node */
810
876
  if(temp_node->children == NULL) {
@@ -1431,8 +1497,10 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
1431
1497
  if (strncmp(n->str,"<!--",4) == 0) {
1432
1498
  /* trim "-->" from end */
1433
1499
  n->str[strlen(n->str)-3] = '\0';
1500
+ // g_string_append(out, "\n\\begin_layout Plain Layout\n\\begin_inset ERT\nstatus collapsed\n\n\\begin_layout Plain Layout\n\n");
1434
1501
  g_string_append(out, "\n\\begin_inset ERT\nstatus collapsed\n\n\\begin_layout Plain Layout\n\n");
1435
1502
  print_lyx_string(out,&n->str[4],scratch,LYX_NONE);
1503
+ // g_string_append(out,"\n\n\\end_layout\n\\end_inset\n\\end_layout\n");
1436
1504
  g_string_append(out,"\n\n\\end_layout\n\\end_inset\n");
1437
1505
  }
1438
1506
  break;
@@ -1499,6 +1567,7 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
1499
1567
  g_string_append(out,"\n\\end_inset");
1500
1568
  g_string_append(out, "\n\\end_layout\n");
1501
1569
  scratch->lyx_table_caption = NULL;
1570
+ scratch->table_alignment = NULL;
1502
1571
  break;
1503
1572
  case TABLESEPARATOR:
1504
1573
  colwidth = 100/scratch->lyx_table_total_cols;
@@ -1651,6 +1720,7 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
1651
1720
  fprintf(stderr,"SOURCEBRANCH\n");
1652
1721
  break;
1653
1722
  case NOTELABEL:
1723
+ case GLOSSARYLABEL:
1654
1724
  break;
1655
1725
  case SUPERSCRIPT:
1656
1726
  g_string_append_printf(out, "\n\\begin_inset script superscript\n\n\\begin_layout Plain Layout\n%s\n\\end_layout\n\n\\end_inset\n",n->str);
@@ -1669,25 +1739,36 @@ void print_lyx_node(GString *out, node *n, scratch_pad *scratch, bool no_newline
1669
1739
  /* print_lyx_endnotes */
1670
1740
  void print_lyx_endnotes(GString *out, scratch_pad *scratch) {
1671
1741
  node *temp_node;
1742
+ bool do_nomenclature;
1672
1743
  scratch->used_notes = reverse_list(scratch->used_notes);
1673
1744
  node *note = scratch->used_notes;
1674
1745
  #ifdef DEBUG_ON
1675
1746
  fprintf(stderr, "start endnotes\n");
1676
1747
  #endif
1677
1748
 
1678
- /* Handle Glossary */
1679
- temp_node = note;
1680
- while (temp_node != NULL){
1681
- if(temp_node->key == GLOSSARYSOURCE){
1749
+ /* Handle Glossary or abbreviations */
1750
+ do_nomenclature = false;
1751
+ if (strcmp(used_abbreviations->str,"")!=0){ // if any abbreviations have been used, print a glossary
1752
+ do_nomenclature = true;
1753
+ } else
1754
+ {
1755
+ temp_node = note;
1756
+ while (temp_node != NULL){
1757
+ if(temp_node->key == GLOSSARYSOURCE){
1758
+ do_nomenclature = true;
1759
+ break;
1760
+ }
1761
+ temp_node = temp_node->next;
1762
+ }
1763
+ }
1764
+
1765
+ if (do_nomenclature){
1682
1766
  g_string_append(out,"\n\\begin_layout Standard");
1683
1767
  g_string_append(out,"\n\\begin_inset CommandInset nomencl_print");
1684
1768
  g_string_append(out,"\nLatexCommand printnomenclature");
1685
1769
  g_string_append(out,"\nset_width \"auto\"\n");
1686
1770
  g_string_append(out,"\n\\end_inset\n");
1687
1771
  g_string_append(out,"\n\\end_layout\n");
1688
- break;
1689
- }
1690
- temp_node = temp_node->next;
1691
1772
  }
1692
1773
 
1693
1774
  if (note == NULL)
@@ -1832,9 +1913,11 @@ void print_lyx_localized_typography(GString *out, unsigned char character, scrat
1832
1913
  /* print_lyx_string - print string, escaping and formatting for LYX */
1833
1914
  void print_lyx_string(GString *out, char *str, scratch_pad *scratch, short environment) {
1834
1915
  char *tmp;
1916
+ char *start;
1835
1917
  unsigned char extended_character;
1836
1918
  if (str == NULL)
1837
1919
  return;
1920
+ start = str; /* Store start of string */
1838
1921
  if (environment == LYX_PLAIN) {
1839
1922
  g_string_append(out,"\n\\begin_layout Plain Layout\n\n");
1840
1923
  }
@@ -1871,7 +1954,7 @@ void print_lyx_string(GString *out, char *str, scratch_pad *scratch, short envir
1871
1954
  } else {
1872
1955
  tmp = str;
1873
1956
  tmp--;
1874
- if (*tmp == ' ') {
1957
+ if ((tmp > start) && (*tmp == ' ')) {
1875
1958
  g_string_append(out,"\n");
1876
1959
  } else {
1877
1960
  g_string_append(out, "\n "); /* add a space */
@@ -1881,14 +1964,14 @@ void print_lyx_string(GString *out, char *str, scratch_pad *scratch, short envir
1881
1964
  case '<': /* look for HTML comment LaTeX escape */
1882
1965
  if ( (environment != LYX_CODE) && (environment != LYX_PLAIN) && (strncmp(str,"<!--",4) == 0)){
1883
1966
  str+=4; /* move past delimeter */
1884
- g_string_append(out, "\n\\begin_inset ERT\nstatus collapsed\n\n\\begin_layout Plain Layout\n\n");
1967
+ g_string_append(out, "\n\\begin_layoutPlain Layout\n\\begin_inset ERT\nstatus collapsed\n\n\\begin_layout Plain Layout\n\n");
1885
1968
  while(strncmp(str,"-->",3) !=0){
1886
1969
  switch (*str){
1887
1970
  case '\\':
1888
1971
  g_string_append(out,"\n\\backslash\n\n");
1889
1972
  break;
1890
1973
  case '\"':
1891
- g_string_append(out,"\n\\begin_inset Quotes erd\n\\end_inset\n");
1974
+ g_string_append(out,"\n\\begin_inset Quotes erd\n\\end_inset\n\\end_layout\n");
1892
1975
  break;
1893
1976
  default:
1894
1977
  g_string_append_c(out,*str);
@@ -2161,3 +2244,19 @@ void print_escaped_node(GString *out, node *n) {
2161
2244
  }
2162
2245
  print_escaped_node_tree(out, n->children);
2163
2246
  }
2247
+ /* escape string - replace double quotes with escaped version */
2248
+ char * escape_string(char *str) {
2249
+ GString *out = g_string_new("");
2250
+ char *clean;
2251
+ while (*str != '\0') {
2252
+ if (*str == '"') {
2253
+ g_string_append(out, "\\\"");
2254
+ } else {
2255
+ g_string_append_c(out, *str);
2256
+ }
2257
+ str++;
2258
+ }
2259
+ clean = out->str;
2260
+ g_string_free(out, false);
2261
+ return clean;
2262
+ }