[英]emacs org-mode: table <td> style
從org-mode導出的默認HTML表具有以下樣式:
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Tom</td>
<td>Cruise</td>
</tr>
<tr>
<td>2</td>
<td>Arnold</td>
<td>Schwarzenegger</td>
</tr>
<tr>
<td>3</td>
<td>Sylvester</td>
<td>Stallone</td>
</tr>
</tbody>
</table>
有什么辦法可以使其變得更緊湊:
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
</tr>
</thead>
<tbody>
<tr><td>1</td><td>Tom</td><td>Cruise</td></tr>
<tr><td>2</td><td>Arnold</td><td>Schwarzenegger</td></tr>
<tr><td>3</td><td>Sylvester</td><td>Stallone</td></tr>
</tbody>
</table>
由於我的表很大,因此由org-mode導出的html文件一直到底部都太長了。
在html緩沖區上執行一個簡單的正則表達式替換就可以了:
(defun compactify-html-table ()
(interactive)
(goto-char (point-min))
(while (re-search-forward "<\\(/?t[rd]\\)>\n<\\(/?t[rd]\\)>" nil t)
(replace-match "<\\1><\\2>"))
(goto-char (point-min))
(while (re-search-forward "\n\n" nil t)
(replace-match "\n")))
(defun compactify-all-html-buffers ()
(interactive)
(mapc
(lambda(b)
(with-current-buffer b
(when (eq major-mode 'html-mode)
(compactify-html-table))))
(buffer-list)))
另一個解決方案是整理HTML輸出。 使用不同的參數,您可以獲得更緊湊的(當然,更加一致的)演示。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.