From 063bdeba9413c17a0d45e985d83d94501d0eea4b Mon Sep 17 00:00:00 2001 From: Jerome Simeon Date: Mon, 21 Sep 2020 15:18:03 -0400 Subject: [PATCH] fix(pdf) headings can now contain different kinds of things Signed-off-by: Jerome Simeon --- packages/markdown-pdf/src/ToPdfMakeVisitor.js | 6 ++---- packages/markdown-pdf/test/data/contract.md | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/markdown-pdf/src/ToPdfMakeVisitor.js b/packages/markdown-pdf/src/ToPdfMakeVisitor.js index 780062af..5c62bffb 100644 --- a/packages/markdown-pdf/src/ToPdfMakeVisitor.js +++ b/packages/markdown-pdf/src/ToPdfMakeVisitor.js @@ -236,11 +236,9 @@ class ToPdfMakeVisitor { } break; case 'Heading': { - const child = this.processChildNodes(thing,parameters); - const text = child && child[0] && child[0].text ? child[0].text : ''; result.style = ToPdfMakeVisitor.getHeadingType(thing); - result.text = `\n${text}\n`; - result.tocItem = text.length > 0 ? true : false; + result.text = this.processChildNodes(thing,parameters); + result.tocItem = thing.nodes && thing.nodes.length > 0 ? true : false; } break; case 'ThematicBreak': { diff --git a/packages/markdown-pdf/test/data/contract.md b/packages/markdown-pdf/test/data/contract.md index 295f0062..d1d9666b 100644 --- a/packages/markdown-pdf/test/data/contract.md +++ b/packages/markdown-pdf/test/data/contract.md @@ -1,5 +1,10 @@ # Title (Heading One) +Title2 +*(Heading Two)* +**on several lines** +---- + This is normal text. This is *italic* text.