Creating a Template

Jacob Campbell's Avatar

Jacob Campbell

09 Sep, 2014 01:55 AM

I'm loving Marked2 (along with all of the stuff you do Brett). I've tried browsing and searching through the support forum, and I haven't come across my use case. It seems like it might take something like creating a preprocessor, but in reading through stuff about it, it's all a little over my head. That being said, I like trying to figure some of that stuff out... I just don't know if that's the direction I need to go.

I write progress notes, letters, evaluations, and other documentation for my clinical practice in markdown. I've been using Marked2 for when I have to actual send my clients something or if it's going to go into a paper file. For example, I like to have letters sent out with a nice letterhead template. My letterhead has a type of left sidebar with a logo with some text below it with my various contact information. I've created a custom CSS to implement this. I added the image as a background with absolute values. I couldn't come up with any way to add the text underneath without including it in the text of my letter. Basically I just write up a little block of HTML with classes, and then I have the CSS style it under the image again using absolute values.

This solution has been working, but it is not really elegant, and I'd rather not have to have that little bit of code cluttering up the content of my letter. I feel like there should be a way to insert that text into the Marked2 preview. This would especially helpful if it could be based on which style I am previewing through. It would be ok if I just had to add some YML Front Matter syntax to the document (i.e. document type: letter).

What would be the best method of trying to make a type of template for some of my previews.

I hope that makes sense,

Thanks.

Jacob Campbell

http://thedesignclinic.org/
http://jacobrcampbell.com/

  1. Support Staff 1 Posted by Brett on 10 Sep, 2014 08:44 PM

    Brett's Avatar

    Your current solution is the best that exists at the moment. I have implemented no means of templating or handling multiple formats at this point. I'll consider it for the future, though.

  2. 2 Posted by Fester Besterte... on 12 Sep, 2014 12:23 AM

    Fester Bestertester's Avatar

    Please add me to your list of those who would like straightforward templating for printing nice looking PDF's with letterhead.

  3. 3 Posted by Jacob Campbell on 15 Sep, 2014 06:38 AM

    Jacob Campbell's Avatar

    Thank you for the response. What I might do, although it makes me cringe a little bit, is put the text and save it as a png file or something like that... then I can add it in as CSS.

    Jacob

  4. 4 Posted by Neill Cohen on 25 Jul, 2016 03:07 AM

    Neill Cohen's Avatar

    I too would appreciate a letterhead template. I'm currently using a LaTex template for this.

  5. Support Staff 5 Posted by Brett on 25 Jul, 2016 02:14 PM

    Brett's Avatar

    Markdown just isn't made for this kind of thing directly. One option is to create an HTML/CSS combination that styles it the way you need, then use metadata replacements to replace the placeholders with metadata from the top of the file. You could use an include statement to incorporate it easily into new files.

    I won't lay out a whole skeleton, but something using spans or list items with unique classes and styling, e.g. <span class="subject">[%subject]</span> could then have a meta entry at the top of the document:

    subject: The subject of the letter
    

    And it would fill in. A custom stylesheet would then style the text as indented, centered, etc. The HTML section could be stored in a re-usable file, and included with:

    <<{letterheadtemplate.html}
    

    Hopefully that helps. If anyone puts something like this together, I'd be happy to include it in the bonus pack on github.

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