Skip to content

Commit e2a20f6

Browse files
committed
pdf - use hasLevelOneHeadings analysis
1 parent 72105dd commit e2a20f6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/format/pdf/format-pdf.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { kTemplatePartials } from "../../command/render/template.ts";
5353
import { copyTo } from "../../core/copy.ts";
5454
import { kCodeAnnotations } from "../html/format-html-shared.ts";
5555
import { safeModeFromFile } from "../../deno_ral/fs.ts";
56+
import { hasLevelOneHeadings as hasL1Headings } from "../../core/lib/markdown-analysis/level-one-headings.ts";
5657

5758
export function pdfFormat(): Format {
5859
return mergeConfigs(
@@ -138,7 +139,7 @@ function createPdfFormat(
138139
metadata: {
139140
["block-headings"]: true,
140141
},
141-
formatExtras: (
142+
formatExtras: async (
142143
_input: string,
143144
markdown: string,
144145
flags: PandocFlags,
@@ -254,7 +255,7 @@ function createPdfFormat(
254255
};
255256

256257
// Don't shift the headings if we see any H1s (we can't shift up any longer)
257-
const hasLevelOneHeadings = !!markdown.match(/\n^#\s.*$/gm);
258+
const hasLevelOneHeadings = await hasL1Headings(markdown);
258259

259260
// pdfs with no other heading level oriented options get their heading level shifted by -1
260261
if (

0 commit comments

Comments
 (0)