simonhaenisch / md-to-pdf

Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
https://www.npmjs.com/md-to-pdf
MIT License
1.16k stars 111 forks source link

Supporting Solidity code in markdown #191

Closed csurbier closed 1 year ago

csurbier commented 1 year ago

Hi,

I don't find how to support the Solidity language code in my markdown with your tool.

https://github.com/highlightjs/highlightjs-solidity

Can anyone help me ? Thanks Christophe

simonhaenisch commented 1 year ago

Hi Christophe,

highlightjs is already included by default, but the solidity support script you'll have to load manually. You can do this by adding downloading solidity.min.js and adding it as a script to the config, e.g. via the front-matter:

---
script:
  - path: /path/to/solidity.min.js
---

<!-- not sure about the language name tbh -->
```solidity
(some code here)


Let me know if this doesn't work then I can reopen the ticket.
csurbier commented 1 year ago

Thank you so much for your answer. I didn't know how to install it. I will try it

Thanks

csurbier commented 1 year ago

Can you confirm me that i'm doing correctly. I have the solidity.min.js file here : /Users/christophesurbier/Dropbox/Christophe/Autonomo/Publishing/solidity_real/solidity.min.js and here is my file markdown :eBook

But when i'm launching the command: cat fullBook.md | md-to-pdf > ebook.pdf

The PDF doesn't have the solidity code highlighted :(

Thanks a lot

csurbier commented 1 year ago

Just see in the highlight-solidity.js package this Compatibility This package is not currently compatible with highlight.js version 11. and in their package.json "devDependencies": { "highlightjs": "^9.12.0", "mocha": "^6.2.1", "parse5": "^5.1.0" }

So added this to my markdown file:

but still not working :(

csurbier commented 1 year ago

For those who are looking for the answer, finally got it working ! Added this at the beginning of my markdown file:


 
 


 

Thanks Christophe