codimd icon indicating copy to clipboard operation
codimd copied to clipboard

HTML is not parsed during PDF conversion

Open mic4ael opened this issue 4 years ago • 0 comments
trafficstars

An example (problematic) note:

Title
=====

<div>
    Hello, world!
</div>

If I export such note to PDF, div block is copied into the output PDF as-is (without any parsing). This is because markdown-pdf is not configured to parse custom HTML. Is that behaviour intended?

If that is an unfortunate omission, the following changed should be enough to fix the issue.

diff --git i/lib/note/noteActions.js w/lib/note/noteActions.js
index 31f7c1f4..f583f0b1 100644
--- i/lib/note/noteActions.js
+++ w/lib/note/noteActions.js
@@ -79,7 +79,10 @@ function actionPDF (req, res, note) {
   const pdfPath = config.tmpPath + '/' + Date.now() + '.pdf'
   content = content.replace(/\]\(\//g, '](' + url + '/')
   const markdownpdfOptions = {
-    highlightCssPath: highlightCssPath
+    highlightCssPath: highlightCssPath,
+    remarkable: {
+      html: true
+    }
   }
   markdownpdf(markdownpdfOptions).from.string(content).to(pdfPath, function () {
     if (!fs.existsSync(pdfPath)) {

mic4ael avatar Nov 09 '21 09:11 mic4ael