Reputation: 2383
I am looking for a Markdown variant of the Htmlize addon.
The idea is simple: say, you wish to publish code to a GIST on GitHub, or any place which supports Markdown. You type your code in Emacs, do M-x markdownize-buffer
and you get a new buffer containing the full Markdown markup.
Anybody knows if such an addon exists?
Upvotes: 1
Views: 399
Reputation: 5776
Markdown isn't powerful enough to generate span classes. To do this, you need to drop down into pure HTML.
Htmlize will generate a syntax-highlighted version of your code based on your current Emacs theme settings. Take a look at the generated markup: it does this by generating both DOM elements and styles to replicate your current syntax highlighting:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!-- Created by htmlize-1.36 in css mode. -->
<html>
<head>
<title>sha1test.rb</title>
<style type="text/css">
<!--
body {
color: #eeeeec;
background-color: #2e3434;
}
.comment {
/* font-lock-comment-face */
color: #888a85;
}
.comment-delimiter {
/* font-lock-comment-delimiter-face */
color: #888a85;
}
/* [...] */
-->
</style>
</head>
<body>
<pre>
require <span class="string">'digest/sha1'</span>
<span class="type">SLICE_SIZE</span> = 20
<span class="keyword">def</span> <span class="function-name">myhash</span>(input)
<span class="type">Digest</span>::<span class="type">SHA1</span>.hexdigest(input).slice(0,<span class="type">SLICE_SIZE</span>)
<span class="keyword">end</span>
hashmap = {}
inputs = 0
unique_inputs = 0
<span class="type">ARGF</span>.each <span class="keyword">do</span> |line, idx|
[...]
</body>
</html>
Markdown can't replicate the kind of information here. It's good for translating semantic plain-text into semantic markup (i.e. headers should turn into H1 or H2, **text**
should generate <strong>text</strong>
, etc.). Which lines of your Emacs buffer are headers? Which should translate into <em>
tags?
Upvotes: 2