从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文件太长而一直到底部。
答案 0 :(得分:1)
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)))
答案 1 :(得分:1)
另一个解决方案是整理HTML输出。使用不同的参数,您可以获得更紧凑(并且肯定,更一致)的演示文稿。