Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm in need of an application that can do something like Marked for OS X does.

The function I need is a bit more specific: I want the app to export Markdown to PDF, but using CSS - I've achieved this using BBEdit (using <link rel="stylesheet" href="file.css" /> and exporting, and with Marked, I can just select the CSS file.

I'm using ReText for Markdown editing, but said method doesn't work - the PDF exportation is posible, but without styling.

Any way to achieve this? I don't mind using the Terminal or any library lying around - if I can achieve the desired results.

share|improve this question

4 Answers 4

up vote 1 down vote accepted

ReText 4.0, recently released, now supports styles (and they are correctly exported to PDF too).

For example, if file you are editing is somefile.mkd, create a stylesheet named somefile.css in the same folder, and that style will be automatically loaded.

share|improve this answer
1  
+1 for retext, great work on it Dmitry! I haven't seen the 4.0 version on launchpad yet though. Your PPA only has 3.1.3 in it. –  Brandon Bertelsen Dec 9 '12 at 7:23
    
THIS! <3 I should look for it, though — haven't seen the 4.0 either. –  AeroCross Dec 10 '12 at 19:38

WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. It aims to support web standards for printing. WeasyPrint is free software made available under the BSD license.

share|improve this answer

I'd recommend using wkhtmltopdf, which you can get by installing the Ubuntu package of the same name (wkhtmltopdf Install wkhtmltopdf).

share|improve this answer

You can use python markdown (from the python-markdown package) and xhtml2pdf (from the python-pisa package).

You could have a script like:

#!/bin/sh

CSS_FILE=~/path/to/style.css

MARKDOWN_FILE=$1.mkd
HTML_FILE=$1.html
PDF_FILE=$1.pdf

markdown_py $MARKDOWN_FILE > $HTML_FILE
xhtml2pdf --quiet --css $CSS_FILE $HTML_FILE $PDF_FILE
rm $HTML_FILE

Put the above code in mkd2pdf, make the file executable (chmod +x mkd2pdf).

Say your markdown file is called file.mkd then you could run

./mkd2pdf file

and you would have file.pdf generated in the same directory. (Note the lack of a suffix in the above line).

share|improve this answer
    
Sigh: CSSParseError: Selector Pseudo Function closing ')' not found:: (u':not(', u'[controls]){display:') *** ERRORS OCCURED when parsing the Minified Bootstrap CSS file. Any way to fail silently or something? This seems like to be the answer. –  AeroCross Mar 19 '12 at 19:01
    
@AeroCross - I've updated the script to add the --quiet flag which should suppress the output. –  Hamish Downer Mar 20 '12 at 13:51
    
That just removes the error output but still errors out and finishes the script abruptly. It's a fine addition tho. Since I tried that again (and edited the file to circumvent problems like pseudo-selectors and propietary prefixes) I still get errors: AttributeError: 'CSSTerminalFunction' object has no attribute 'lower' *** ERRORS OCCURED - that's a bug in python-pisa, for what I can see. Any other tool? –  AeroCross Mar 23 '12 at 15:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.