|
1 | 1 | import marked from 'marked'; |
| 2 | +import htmlToPdfmake from 'html-to-pdfmake'; |
2 | 3 | import { rowLinesTableLayout } from '@/table-layouts'; |
3 | | -import { getMarkDownDef } from '@/markdown'; |
4 | 4 | import { |
5 | 5 | getTypeInfo, |
6 | 6 | schemaInObjectNotation, |
7 | 7 | objectToTree, |
8 | 8 | objectToTableTree, |
9 | 9 | } from '@/object-tree-gen'; |
10 | 10 |
|
| 11 | +function markdownToPdfmake(markdown) { |
| 12 | + const html = marked(markdown); |
| 13 | + return htmlToPdfmake(html); |
| 14 | +} |
| 15 | + |
11 | 16 | // Info Def |
12 | 17 | export function getInfoDef(spec, bookTitle, localize) { |
13 | 18 | let content; |
@@ -46,9 +51,8 @@ export function getInfoDef(spec, bookTitle, localize) { |
46 | 51 |
|
47 | 52 | let specInfDescrMarkDef; |
48 | 53 | if (spec.info.description) { |
49 | | - const tokens = marked.lexer(spec.info.description); |
50 | 54 | specInfDescrMarkDef = { |
51 | | - stack: getMarkDownDef(tokens), |
| 55 | + stack: markdownToPdfmake(spec.info.description), |
52 | 56 | style: ['topMargin3'], |
53 | 57 | }; |
54 | 58 | } else { |
@@ -337,20 +341,17 @@ export function getApiDef(spec, filterPath, schemaStyle, localize, includeExampl |
337 | 341 | }); |
338 | 342 | operationContent.push({ text: '', style: ['topMarginRegular'] }); |
339 | 343 |
|
340 | | - let pathSummaryMarkDef; let pathDescrMarkDef; let |
341 | | - tokens; |
| 344 | + let pathSummaryMarkDef; let pathDescrMarkDef; |
342 | 345 | if (path.summary) { |
343 | | - tokens = marked.lexer(path.summary); |
344 | 346 | pathSummaryMarkDef = { |
345 | | - stack: getMarkDownDef(tokens), |
| 347 | + stack: markdownToPdfmake(path.summary), |
346 | 348 | style: ['primary', 'b'], |
347 | 349 | }; |
348 | 350 | operationContent.push(pathSummaryMarkDef); |
349 | 351 | } |
350 | 352 | if (path.description && path.description.trim() !== path.summary.trim()) { |
351 | | - tokens = marked.lexer(path.description); |
352 | 353 | pathDescrMarkDef = { |
353 | | - stack: getMarkDownDef(tokens), |
| 354 | + stack: markdownToPdfmake(path.description), |
354 | 355 | }; |
355 | 356 | operationContent.push(pathDescrMarkDef); |
356 | 357 | } |
@@ -418,12 +419,10 @@ export function getApiDef(spec, filterPath, schemaStyle, localize, includeExampl |
418 | 419 |
|
419 | 420 | if (pathSeq > 0) { |
420 | 421 | tagSeq += 1; |
421 | | - let tagDescrMarkDef; let |
422 | | - tokens; |
| 422 | + let tagDescrMarkDef; |
423 | 423 | if (tag.description) { |
424 | | - tokens = marked.lexer(tag.description); |
425 | 424 | tagDescrMarkDef = { |
426 | | - stack: getMarkDownDef(tokens), |
| 425 | + stack: markdownToPdfmake(tag.description), |
427 | 426 | style: ['topMarginRegular'], |
428 | 427 | }; |
429 | 428 | } else { |
|
0 commit comments