Skip to content

Commit 9224820

Browse files
committed
Some minor refactorings
1 parent a0d1a59 commit 9224820

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

bin/markdown-to-pdf.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ function createPdf(html, pdfPath, options) {
246246

247247
let markdown = fs.readFileSync(source, 'utf-8')
248248

249+
if (addToc) {
250+
markdown = addTocToMarkdown(markdown, {
251+
indent: '\t',
252+
maxdepth,
253+
})
254+
}
255+
256+
//
257+
// Generate CSS and HTML from markdown
258+
//
249259
const cssStyleFiles = [
250260
path.join(__dirname, '../styles/github-markdown-css.css'),
251261
path.join(__dirname, '../styles/default.css'),
@@ -256,14 +266,7 @@ const cssStyle = cssStyleFiles
256266
.map(file => fs.readFileSync(file, 'utf-8').replace(/\r\n/g, '\n'))
257267
.join('\n')
258268

259-
if (addToc) {
260-
markdown = addTocToMarkdown(markdown, {
261-
indent: '\t',
262-
maxdepth,
263-
})
264-
}
265-
266-
const htmlContent = markdownToHtml(markdown)
269+
const htmlMarkdownContent = markdownToHtml(markdown)
267270

268271
let html = `
269272
<!DOCTYPE html>
@@ -273,7 +276,7 @@ let html = `
273276
<style>${cssStyle}</style>
274277
</head>
275278
<body class="markdown-body">
276-
${htmlContent}
279+
${htmlMarkdownContent}
277280
</body>
278281
</html>
279282
`

0 commit comments

Comments
 (0)