一批把法律文本的标题转换为 wikitext 层级标题的 Emacs 函数: Difference between revisions
Created page with "一批 Emacs 函数,可以很方便地处理国家法律数据库中等各处下载下来的法律文本,使其标题以 wikitext 形式呈现。具体排版效果可参见本站 宪法 分享的法条。 == 从其他地方下载的法律文本通用处理 == <syntaxhighlight lang="elisp" line> (defun convert-legal-headers-to-wikitext () "将当前 buffer 中的法律文书标题转换为 mediawiki wikitext 层级格式。 对以“第…编”、“第…章..." |
No edit summary |
||
| Line 72: | Line 72: | ||
(goto-char (point-min)) | (goto-char (point-min)) | ||
(insert "{{#css: \n.tocnumber { display: none; }\n}}\n")) | (insert "{{#css: \n.tocnumber { display: none; }\n}}\n")) | ||
</syntaxhighlight> | |||
== 小部头法律编号升一升 == | |||
<syntaxhighlight lang="elisp" line> | |||
(defun my-replace-equals () | |||
"把所有 === 替换为 == 。" | |||
(interactive) | |||
(save-excursion | |||
(goto-char (point-min)) | |||
(while (search-forward "===" nil t) | |||
(replace-match "==")))) | |||
;; 绑定到 C-c j | |||
(global-set-key (kbd "C-c j") 'my-replace-equals) | |||
</syntaxhighlight> | </syntaxhighlight> | ||