Skip to content

Commit

Permalink
adds PDF generation
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Griffin <griffin.kev@gmail.com>
  • Loading branch information
m00sey committed Jan 27, 2024
1 parent c6298b9 commit 1615d62
Show file tree
Hide file tree
Showing 5 changed files with 3,879 additions and 129 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ Be sure to remove references to `specification-template` in favor of your new sp

### Experimental PDF generation

To output a PDF (on macOS, requires Python)

`# brew install pandoc`
`# brew install librsvg homebrew/cask/basictex`

`# python combine.py`
`# chmod +x pdf.sh`
`# ./pdf.sh`
Run `npm run pdf` to render the pdf.

#### Contributing

Expand Down
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,27 @@ module.exports = function(options = {}) {
}
}

if (options.pdf) {
const path = require('path');
const mdToPdf = require('md-to-pdf');

var buf;
config.specs.forEach(spec => {
spec.markdown_paths.map(p => {
buf += fs.readFileSync(spec.spec_directory + path.sep + p);
buf += '\n\n';
});

console.log(spec);
let title = spec.title
(async () => {
await mdToPdf({ content: buf }, { dest: 'output.pdf' }).catch(console.error);
})().then(() => {
process.exit(0);
}).catch(() => process.exit(1));
});
}

config.specs.forEach(spec => {
spec.spec_directory = normalizePath(spec.spec_directory);
spec.destination = normalizePath(spec.output_path || spec.spec_directory);
Expand Down
Loading

0 comments on commit 1615d62

Please sign in to comment.