Are there any tutorials/articles on getting started with preprocessors?

Dre Jones's Avatar

Dre Jones

03 Sep, 2014 08:25 PM

I'd like to be able to add a simple cover page when exporting PDFs that lists some MMD meta tags (title, date etc) and some classes for styling. From what I've read, it seems I could do this using a custom preprocessor. Unfortunately, all the articles and tutorials I've found tend to skim over how to do this: I can muddle my way through some Python, but are does anyone know of any articles that could help? The biggest stumbling block I'm having at the moment is that I can't figure out how you actually pass the MMD meta to the processor. Any help would be greatly appreciated

  1. Support Staff 1 Posted by Brett on 03 Sep, 2014 08:37 PM

    Brett's Avatar

    You could actually do this in the document by using [%variable] holders
    and a <!--BREAK--> to start a new page after.

    Custom processors (and preprocessors) just take input on STDIN and
    return output on STDOUT. Everything in between is up to the user. If
    your content contains MMD headers, they're passed as is to a
    preprocessor and it's up to the script to read and interpret them.

    -Brett

  2. 2 Posted by Dre on 04 Sep, 2014 10:02 AM

    Dre's Avatar

    Thanks for the reply; that clarifies things somewhat. Since webkit doesn’t support @page, I’ll need to add some additional HTML so I can style the first page differently, so it looks like I’ll have to go the
    preprocessor route. I somehow got it in my head that the MMD would get piped to the script as some kind of variable; I’m guessing I use Regex to get the meta values (unless there’s a more effective way).

    Thanks!

  3. Support Staff 3 Posted by Brett on 04 Sep, 2014 12:18 PM

    Brett's Avatar

    Another option would be to use straight HTML in a separate file, then
    include it in your documents with one of the include syntaxes (probably
    a raw include <<{filename.html}). If you did use a processed include
    (<<[filename.md]) containing HTML, you'd have access to variables in the
    head using the [%variable] methods.

    -Brett

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac