Skip to content

Commit d3c6eec

Browse files
authored
fix(markdown-pdf): crash with empty headings (#293)
Signed-off-by: Dan Selman <[email protected]>
1 parent 6d0f440 commit d3c6eec

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/markdown-pdf/src/ToPdfMakeVisitor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ class ToPdfMakeVisitor {
222222
break;
223223
case 'Heading': {
224224
const child = this.processChildNodes(thing,parameters);
225+
const text = child && child[0] && child[0].text ? child[0].text : '';
225226
result.style = ToPdfMakeVisitor.getHeadingType(thing);
226-
result.text = `\n${child[0].text}\n`;
227-
result.tocItem = true;
227+
result.text = `\n${text}\n`;
228+
result.tocItem = text.length > 0 ? true : false;
228229
}
229230
break;
230231
case 'ThematicBreak': {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Cicero 0.21 Migration
2+
====
3+
4+
Demo Day Aug 19th!
5+
----
6+
7+
##
8+
9+
{{#clause f30a9f03-8d0f-481a-81bb-4a64f46ab297 src="ap://[email protected]#5d2fd778622e85e0f9224be383df3db2d4dfdc878d70b94a0a6231d53b3bf5ee"}}
10+
Acceptance of Delivery.
11+
----
12+
13+
"Barilla" will be deemed to have completed its delivery obligations
14+
if in "Acme"'s opinion, the "Pasta" satisfies the
15+
Acceptance Criteria, and "Acme" notifies "Barilla" in writing
16+
that it is accepting the "Pasta".
17+
18+
Inspection and Notice.
19+
----
20+
21+
"Acme" will have 10 Business Days to inspect and
22+
evaluate the "Pasta" on the delivery date before notifying
23+
"Barilla" that it is either accepting or rejecting the
24+
"Pasta".
25+
26+
Acceptance Criteria.
27+
----
28+
29+
The "Acceptance Criteria" are the specifications the "Pasta"
30+
must meet for the "Barilla" to comply with its requirements and
31+
obligations under this agreement, detailed in "Attachment X", attached
32+
to this agreement.
33+
{{/clause}}
34+
35+
{{#clause 1e3ba696-a406-4eb4-ac65-b969a7f950ae src="deyway://[email protected]#4a2690f74dea49b151a410a2d0ea23bbd7c3860c8e9daf240747ec45f46383de"}}
36+
Fixed rate loan
37+
----
38+
39+
This is a *fixed interest* loan to the amount of £100,000.00
40+
at the yearly interest rate of 2.5%
41+
with a loan term of 15,
42+
and monthly payments of {{%"£667.00"%}}
43+
{{/clause}}

0 commit comments

Comments
 (0)