views:

286

answers:

1

In TextMate there is a feature called "Create HTML from Document", which converts displayed code including syntax coloring to HTML/CSS for easy online publishing. I wonder if there is such a feature hidden in Emacs or maybe an extension that I could install to do that.

+12  A: 

Htmlize.

Here, I used htmlize-region to Htmlize a section of the GNU Emacs Welcome screen:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!-- Created by htmlize-1.34 in css mode. -->
<html>
  <head>
    <title>*GNU Emacs*</title>
    <style type="text/css">
    <!--
      body {
        color: #000000;
        background-color: #ffffff;
      }
      .ATTRLIST {
      }
      .ATTRLIST-1 {
        /* (:foreground "darkblue") */
        color: #00008b;
      }
      .ATTRLIST-2 {
        /* (:slant oblique) */
        font-style: italic;
      }
      .ATTRLIST-3 {
        /* (:foreground "red") */
        color: #ff0000;
      }
      .default {
        /* default */
        color: #000000;
        background-color: #ffffff;
      }
      .link {
        /* link */
        color: #0000ff;
        text-decoration: underline;
      }
      .variable-pitch {
      }

      a {
        color: inherit;
        background-color: inherit;
        font: inherit;
        text-decoration: inherit;
      }
      a:hover {
        text-decoration: underline;
      }
    -->
    </style>
  </head>
  <body>
    <pre>
<span class="ATTRLIST-3"><span class="variable-pitch">Welcome to </span></span><span class="ATTRLIST"><span class="link">GNU Emacs</span></span><span class="ATTRLIST-3"><span class="variable-pitch">, one component of the </span></span><span class="ATTRLIST"><span class="link">GNU/Linux</span></span><span class="ATTRLIST-3"><span class="variable-pitch"> operating system.
</span></span><span class="variable-pitch">To quit a partially entered command, type </span><span class="default">Control-g</span><span class="variable-pitch">.

</span><span class="variable-pitch"><span class="link">Emacs Tutorial</span></span><span class="variable-pitch">        Learn basic keystroke commands
</span><span class="variable-pitch"><span class="link">Emacs Guided Tour</span></span><span class="variable-pitch">     Overview of Emacs features
</span><span class="variable-pitch"><span class="link">View Emacs Manual</span></span><span class="variable-pitch">     View the Emacs manual using Info
</span><span class="variable-pitch"><span class="link">Absence of Warranty</span></span><span class="variable-pitch">   GNU Emacs comes with </span><span class="ATTRLIST-2"><span class="variable-pitch">ABSOLUTELY NO WARRANTY
</span></span><span class="variable-pitch"><span class="link">Copying Conditions</span></span><span class="variable-pitch">    Conditions for redistributing and changing Emacs
</span><span class="variable-pitch"><span class="link">Ordering Manuals</span></span><span class="variable-pitch">      Purchasing printed copies of manuals</span>
<span class="variable-pitch">
To start...     </span><span class="variable-pitch"><span class="link">Open a File</span></span><span class="variable-pitch">     </span><span class="variable-pitch"><span class="link">Open Home Directory</span></span><span class="variable-pitch">     </span><span class="variable-pitch"><span class="link">Customize Startup</span></span><span class="variable-pitch">
</span><span class="ATTRLIST-1"><span class="variable-pitch">
This is GNU Emacs 22.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.14.7)
 of 2009-03-31 on nautilus, modified by Debian</span></span></pre>
  </body>
</html>
Cirno de Bergerac