cakebake / markdown-themeable-pdf

ARCHIVED. NOT MAINTAINED. Themeable Markdown Converter (Print to PDF, HTML, JPEG or PNG)
https://atom.io/packages/markdown-themeable-pdf
133 stars 37 forks source link

In file params #55

Closed JoseMCO closed 6 years ago

JoseMCO commented 8 years ago

Grabs a definition of MTP (as Json) in the file comments (if there's one) and save it as fileParams in the jobInfo variable.

Also if there's an "outputDir" definition on MTP, uses that as the new path for the generated pdf. (this last option was added as a quick solution for issue #44)

For example:

<!--
  MTP = {
    "author": "José Castro",
    "outputDir": "pdf/out.pdf"
  }
-->

will expose author and outputDir via info.fileParams to use on the custom header or footer and the generated pdf will be saved as out.pdf in the pdf folder.

cakebake commented 8 years ago

Thanks and good idea, but I could not find the code related to author informations on ba4c55b8c2b95c198b6476daaf631296a7a72e73

JoseMCO commented 8 years ago

author is just an example, it could be anything and the idea is that you can pass variables to use in the header or footer, e.g.:

// file.md
<!--
  MTP = {
    "author": "José Castro",
    "project": "Documentation"
  }
-->
...

and on the custom header

// header.js
module.exports = function (info) {
    var project = (info.fileParams && info.fileParams.project) ? "Project" : info.fileParams.project;
    var author = (info.fileParams && info.fileParams.author) ? "Anon" : info.fileParams.author;
    return {
        height: '1cm',
        contents: '<div id="page-header" style="text-align: right;">'+project+' written by '+author+'</div>'
    };
};

will print "Documentation written by José Castro" on the header of the pdf

cakebake commented 6 years ago

Fixed in #44 by save dialog