'use strict'; // Markdown, as WeKan renders it, for a file rather than for a browser. // // WHY THIS EXISTS. A card's description, its comments and its checklist items // are markdown, and WeKan draws them as markdown everywhere it shows them. The // exports did not: the PDF flattened `**bold**` to the word with its asterisks // still on, and Excel wrote the source text into a cell. So a card that reads // well on screen exported as something nobody would write on purpose - which is // the complaint in wekan/wekan#6586, "markdown is not formatted - this doesn't // make sense in a pdf file, does it?" // // ONE PARSE, TWO MEDIA. Both exporters ask this module, and it answers in a // shape neither of them is: a list of BLOCKS, each carrying RUNS of styled text. // // [{ type: 'heading', level: 2, runs: [{ text: 'Plan', bold: true }] }, // { type: 'bullet', level: 0, runs: [{ text: 'first' }] }, // { type: 'code', text: 'npm install' }] // // A run is `{ text, bold, italic, code, strike, link }`. What a medium does with // that is its own business: the PDF picks one of the four Courier faces and // indents; Excel builds an ExcelJS `richText` array. Neither has to know // markdown, and a fix to how a list nests reaches both at once. // // THE SAME PARSER, THE SAME OPTIONS. `packages/markdown/src/template-integration.js` // renders what a reader sees with markdown-it and // `{ html: true, linkify: true, typographer: true, breaks: true }`; this uses // markdown-it with the same four, so the export agrees with the screen about // what is emphasis, what is a list and where a paragraph ends. It does NOT // render HTML: an export is a document, and a card that contains `