<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://qingliezhiquan.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0</id>
	<title>一个把 wikitext 转换成 markdown 的 Emacs 函数 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://qingliezhiquan.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0"/>
	<link rel="alternate" type="text/html" href="https://qingliezhiquan.com/mediawiki/index.php?title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0&amp;action=history"/>
	<updated>2026-08-07T04:55:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://qingliezhiquan.com/mediawiki/index.php?title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0&amp;diff=11476&amp;oldid=prev</id>
		<title>Mwroot at 13:24, 19 July 2026</title>
		<link rel="alternate" type="text/html" href="https://qingliezhiquan.com/mediawiki/index.php?title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0&amp;diff=11476&amp;oldid=prev"/>
		<updated>2026-07-19T13:24:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:24, 19 July 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight lang=&quot;elisp&quot; line&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;pre&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(defun wikitext-convert-all (&amp;amp;optional start end)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(defun wikitext-convert-all (&amp;amp;optional start end)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &amp;quot;Convert simple wikitext to GFM markdown.&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &amp;quot;Convert simple wikitext to GFM markdown.&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l99&quot;&gt;Line 99:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 99:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       (widen))))&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       (widen))))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;pre&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key selfmoney_wiki:diff:1.41:old-11475:rev-11476:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Mwroot</name></author>
	</entry>
	<entry>
		<id>https://qingliezhiquan.com/mediawiki/index.php?title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0&amp;diff=11475&amp;oldid=prev</id>
		<title>Mwroot: Created page with &quot;&lt;syntaxhighlight lang=&quot;elisp&quot; line&gt; (defun wikitext-convert-all (&amp;optional start end)   &quot;Convert simple wikitext to GFM markdown.&quot;    (interactive    (if (use-region-p)        (list (region-beginning) (region-end))      (list (point-min) (point-max))))    (save-excursion     (save-restriction       (narrow-to-region start end)        ;; --------------------------------------------------       ;; 1. inline &lt;code&gt;       ;; --------------------------------------------------...&quot;</title>
		<link rel="alternate" type="text/html" href="https://qingliezhiquan.com/mediawiki/index.php?title=%E4%B8%80%E4%B8%AA%E6%8A%8A_wikitext_%E8%BD%AC%E6%8D%A2%E6%88%90_markdown_%E7%9A%84_Emacs_%E5%87%BD%E6%95%B0&amp;diff=11475&amp;oldid=prev"/>
		<updated>2026-07-19T13:23:51Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;elisp&amp;quot; line&amp;gt; (defun wikitext-convert-all (&amp;amp;optional start end)   &amp;quot;Convert simple wikitext to GFM markdown.&amp;quot;    (interactive    (if (use-region-p)        (list (region-beginning) (region-end))      (list (point-min) (point-max))))    (save-excursion     (save-restriction       (narrow-to-region start end)        ;; --------------------------------------------------       ;; 1. inline &amp;lt;code&amp;gt;       ;; --------------------------------------------------...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;elisp&amp;quot; line&amp;gt;&lt;br /&gt;
(defun wikitext-convert-all (&amp;amp;optional start end)&lt;br /&gt;
  &amp;quot;Convert simple wikitext to GFM markdown.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  (interactive&lt;br /&gt;
   (if (use-region-p)&lt;br /&gt;
       (list (region-beginning) (region-end))&lt;br /&gt;
     (list (point-min) (point-max))))&lt;br /&gt;
&lt;br /&gt;
  (save-excursion&lt;br /&gt;
    (save-restriction&lt;br /&gt;
      (narrow-to-region start end)&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 1. inline &amp;lt;code&amp;gt;&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;code&amp;gt;\\([^&amp;lt;\n]*\\)&amp;lt;/code&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match (concat &amp;quot;`&amp;quot; (match-string 1) &amp;quot;`&amp;quot;) t t))&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;code&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match &amp;quot;`&amp;quot;))&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;/code&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match &amp;quot;`&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 2. syntaxhighlight&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;syntaxhighlight\\s-+lang=[\&amp;quot;&amp;#039;]\\([^\&amp;quot;&amp;#039;]+\\)[\&amp;quot;&amp;#039;][^&amp;gt;]*&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match (concat &amp;quot;```&amp;quot; (match-string 1)) t t))&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match &amp;quot;```&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 3. 列表 # → *&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (let ((in-code-block nil))&lt;br /&gt;
        (goto-char (point-min))&lt;br /&gt;
        (while (not (eobp))&lt;br /&gt;
          (let ((line (thing-at-point &amp;#039;line t)))&lt;br /&gt;
            (when (string-match &amp;quot;^```&amp;quot; line)&lt;br /&gt;
              (setq in-code-block (not in-code-block)))&lt;br /&gt;
            (unless in-code-block&lt;br /&gt;
              (beginning-of-line)&lt;br /&gt;
              (while (search-forward &amp;quot;#&amp;quot; (line-end-position) t)&lt;br /&gt;
                (replace-match &amp;quot;*&amp;quot;))))&lt;br /&gt;
          (forward-line 1)))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 4. headings&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (dolist (n &amp;#039;(6 5 4 3 2))&lt;br /&gt;
        (goto-char (point-min))&lt;br /&gt;
        (let ((pat (format &amp;quot;^=\\{%d\\}[ \t]*\\(.*?\\S-\\)[ \t]*=\\{%d\\}[ \t]*$&amp;quot; n n))&lt;br /&gt;
              (rep (concat (make-string n ?#) &amp;quot; \\1&amp;quot;)))&lt;br /&gt;
          (while (re-search-forward pat nil t)&lt;br /&gt;
            (replace-match rep))))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 5. &amp;lt;del&amp;gt; -&amp;gt; ~~&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;del&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match &amp;quot;~~&amp;quot;))&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;&amp;lt;/del&amp;gt;&amp;quot; nil t)&lt;br /&gt;
        (replace-match &amp;quot;~~&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 6. ---- -&amp;gt; ---&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;^----[ \t]*$&amp;quot; nil t)&lt;br /&gt;
        (replace-match &amp;quot;---&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 11-12. 行首 ; / : 处理&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;^; \\(.*\\)$&amp;quot; nil t)&lt;br /&gt;
        (replace-match (concat &amp;quot;&amp;lt;strong&amp;gt;&amp;quot; (match-string 1) &amp;quot;&amp;lt;/strong&amp;gt;&amp;quot;) nil nil))&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward &amp;quot;^: \\(.*\\)$&amp;quot; nil t)&lt;br /&gt;
        (replace-match (match-string 1) nil nil))&lt;br /&gt;
&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      ;; 13. [[File:xxx]] -&amp;gt; ![xxx]()&lt;br /&gt;
      ;; --------------------------------------------------&lt;br /&gt;
      (goto-char (point-min))&lt;br /&gt;
      (while (re-search-forward&lt;br /&gt;
              &amp;quot;\\[\\[File:\\([^]|]+\\)\\.[a-zA-Z0-9]+[^]]*\\]\\]&amp;quot;&lt;br /&gt;
              nil t)&lt;br /&gt;
        (replace-match&lt;br /&gt;
         (format &amp;quot;![%s]()&amp;quot; (match-string 1))&lt;br /&gt;
         t t))&lt;br /&gt;
&lt;br /&gt;
      (widen))))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mwroot</name></author>
	</entry>
</feed>