1

There are a lot of markdown-related packages available, at least these two have a markdown command:

$apt search markdown
...
discount/jammy,now 2.2.7-2 amd64 [installed]
  implementation of the Markdown markup language in C
...
markdown/jammy,jammy 1.0.1-10.1 all
  Text-to-HTML conversion tool
...

$ apt show discount
Package: discount
Version: 2.2.7-2
Priority: optional
Section: universe/text
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Alessandro Ghedini <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 113 kB
Depends: libc6 (>= 2.34), libmarkdown2 (= 2.2.7-2)
Conflicts: libtext-markdown-perl, markdown
Homepage: http://www.pell.portland.or.us/~orc/Code/discount/
Download-Size: 26,0 kB
APT-Manual-Installed: yes
APT-Sources: http://de.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Description: implementation of the Markdown markup language in C
 Discount is an implementation of John Gruber's Markdown markup language. It
 implements all of the language described in the Markdown syntax document and
 passes the Markdown 1.0 test suite.
 .
 This package provides the discount executables.

$ apt show markdown
Package: markdown
Version: 1.0.1-10.1
Priority: optional
Section: universe/web
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Matt Kraai <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 58,4 kB
Depends: perl (>= 5.6.0-0.1)
Homepage: http://daringfireball.net/projects/markdown/
Download-Size: 17,6 kB
APT-Sources: http://de.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Description: Text-to-HTML conversion tool
 Markdown is a text-to-HTML conversion tool for web writers.  It
 allows you to write using an easy-to-read, easy-to-write plain text
 format, then convert it to structurally valid XHTML (or HTML).

$ discount
Command 'discount' not found, did you mean:

$ markdown --version
markdown: discount 2.2.7 GITHUB_CHECKBOX

The former has documentation at https://www.pell.portland.or.us/~orc/Code/discount/ and a code mirror at https://github.com/Orc/discount.

markdown -o <out>.html <in>.md writes the file, but to my surprise does not generate a complete HTML file (DOCTYPE, <html> etc.).

Am I missing an option? How can the output be wrapped to make it valid HTML?

2 Answers 2

1
mkd2html <in> <out>
1

This answer doesn't work, but might spark ideas, or save someone else the time of investigating it:

A Markdown file processed by 'markdown' can contain HTML tags directly, so: Embed the HTML header and footer tags in your markdown document like this:

$ cat mydoc.md
<html>
<head><title>My Title</title></head>
<body>

The rest of my markdown doc goes here

</body>
</html>

Then process it with 'markdown', as normal:

markdown mydoc.md >mydoc.html

This almost works, but surrounds the given HTML header and footer tags with paragraph tags:

<p><html>
<head><title>hello</title></head>
<body></p>

The rest of my doc (Transformed to HTML)

<p></body>
</html></p>

Firefox displays this document just fine, and displays the given 'title' in the tab header. But then again, Firefox correctly displays the simple HTML fragment output by 'markdown' by default.

The erroneous <p> tags are included regardless of whether I give the '-fhtml' command-line arg to allow providing HTML tags like this, and whether the HTML tags in mydoc.md are surrounded by a full blank line of whitespace (which is a requirement in some markdown parsers).

Curses! so close!

You must log in to answer this question.

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