将语法突出显示的代码转换为Emacs中的HTML

前端之家收集整理的这篇文章主要介绍了将语法突出显示的代码转换为Emacs中的HTML前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在TextMate中,有一个名为“从文档创建 HTML”的功能,它将显示代码(包括语法着色)转换为HTML / CSS,以便于在线发布.
我想知道Emacs中是否隐藏了这样一个功能,或者也许是我可以安装的扩展功能.

解决方法

Htmlize.

在这里,我使用htmlize-region来Htmlize GNU Emacs欢迎屏幕的一部分:

<!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>

猜你在找的HTML相关文章