4

I was looking for a way to print a markdown file from command line. I usually use lp for simple text files; I want to use something like that, but for markdown.

Also it would be great that this printing could take care of hyphenation (my actual approach to this does not).

In a more general way it would be fantastic to print many more types of files from command line.


Edit: Notice that it's possible to add a mime type to the lp command. For example:

lp -o document-format=text/x-markdown file.md

Of course the problem with this is that the my printing system (cups) doesn't allow this type of document.


Solution: A friend told me about a way to accomplish this. A series of pipes.
markdown file.md -> .md to .html
iconv -f utf-8 -t iso-8859-1 -> utf-8 to iso-8859-1
html2ps -> html to postscript
lp -> print

Finally

markdown file.md | iconv -f utf-8 -t iso-8859-1 | html2ps | lp

Does the trick


The bad: This does not accomplish the hyphenation part (at least I don't think so). My friend told me that in order to accomplish this is better to use pandoc to convert a file from markdown to LaTeX and then print that.

2 Answers 2

0

There are command-line tools for converting markdown to text; you could then pipe it to something like lp or a2ps or similar.

1
  • That doesn't solve the issue at all, if I wanted to print a plain text file I would print a plain text file. If I make a markdown file, I expect to get formatted output.
    – texdditor
    Sep 8, 2014 at 2:52
0

Solution: A friend told me about a way to accomplish this. A series of pipes.
markdown file.md -> .md to .html
iconv -f utf-8 -t iso-8859-1 -> utf-8 to iso-8859-1
html2ps -> html to postscript
lp -> print

Finally

markdown file.md | iconv -f utf-8 -t iso-8859-1 | html2ps | lp

Does the trick

The bad: This does not accomplish the hyphenation part (at least I don't think so). My friend told me that in order to accomplish this is better to use pandoc to convert a file from markdown to LaTeX and then print that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .