-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow Links to Combine Documents #34
Comments
Thanks for the request 🙂 However I think it might be out of scope for this package. Depending on the platform you're on, it's relatively straight-forward to combine multiple PDFs into one (e. g. on macOS you can use Preview.app and drag-and-drop them together). There's also lots of apps and other npm packages out there to merge PDFs... try searching for "pdf merge" on npm. Can you please try see if there's any simple solution for this by using another package/cli tool/app? |
It might be cool if you could pass in a stream into
Otherwise @shellscape you could use concat to join the files to an intermediate one, and then use that in |
@StephenLarkin reading from stdin is one thing I want to implement in the next major release 👍 But it'll probably take a bit till I have the time to do it... |
After @gigaga asked for something similar (he suggested a const { readFileSync } = require('fs');
const { Renderer } = require('marked');
const getMarked = require('md-to-pdf/lib/get-marked-with-highlighter');
const renderer = new Renderer();
const originalLinkRenderer = renderer.link.bind(renderer);
renderer.link = (href, title, text) => {
if (text !== 'include') {
return originalLinkRenderer(href, title, text);
}
// 1. read file
const md = readFileSync(href, 'utf-8');
// 2. get marked instance that's equivalent to the one from md-to-pdf
const marked = getMarked(marked_options);
// 3. convert file to html string
return marked(md);
};
const marked_options = { renderer };
module.exports = { marked_options }; I made a Gist that you can clone if you want to try it out:
|
Thanks a lot! It's perfect!! |
I just made a prerelease of version 3, you can try it out with concat 1.md 2.md 3.md | md-to-pdf It will generate a file concat 1.md 2.md 3.md | md-to-pdf > my-file.pdf |
I'd like to request the ability to instruct the parser to follow file links to other markdown files, to combine multiple documents into one.
The text was updated successfully, but these errors were encountered: