2009-06-03 44 views
9

在TextMate中,有一項名爲「從文檔創建HTML」的功能,該功能將顯示的代碼(包括語法着色)轉換爲HTML/CSS以便於在線發佈。 我想知道是否有這樣的功能隱藏在Emacs中,或者可能是我可以安裝的擴展功能。在Emacs中將語法突出顯示的代碼轉換爲HTML

回答

19

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> 
相關問題