gpt4 book ai didi

Stack Overflow 的 Markdown 的 Emacs 模式

转载 作者:行者123 更新时间:2023-12-03 04:56:49 24 4
gpt4 key购买 nike

我在 Emacs 中使用 Org-mode 来处理我的所有技术文档。我想使用 Emacs 来准备 Stack Overflow 上的问题。是否有 Emacs 模式,或者更好的是 Org 模式的扩展来处理 Stack Overflow 格式?理想情况下,它应该包括 Stack Overflow 问题/评论缓冲区中使用的 markdown 语法支持的所有格式选项。

最佳答案

将 Emacs 与 Stack Overflow 集成

As mentioned您可以使用markdown-mode 。要将 markdown 模式与 Stack Overflow 集成,您可以使用 Firefox 插件 It's All Text它允许您使用外部编辑器编辑文本区域。设置方法如下:

  1. 安装 markdown-mode 。如果您使用 Debian 或 Ubuntu,您可以通过发出安装它

    sudo apt-get install emacs-goodies-el

    或者如果您使用的是 emacs 24(或者 emacs 23 上有 package.el)和 MarmaladeMelpa你可以安装它

    M-x package-install RET markdown-mode
  2. 安装 It's All Text .

  3. 将 It's All Text 的首选项设置为使用 Emacs。您可以将其设置为可执行文件(例如/usr/bin/emacs)或 the emacsclient .
  4. 将以下内容添加到您的 .emacs 中,为 Stack Overflow 和 Stack Exchange 文本区域启用 Markdown 模式:

    ;; Integrate Emacs with Stack Exchange https://stackoverflow.com/a/10386560/789593
    (add-to-list 'auto-mode-alist '("stack\\(exchange\\|overflow\\)\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))

    或者,如果 as-external-alist已定义—if M-x describe-variable RET as-external-alist不会失败——它可能会覆盖你的 auto-mode-alist 。它的格式略有不同(它是对的列表,而不是 cons 单元的列表),因此这将起作用:

    (add-to-list 'as-external-alist '("stack\\(exchange\\|overflow\\)\\.com\\.[a-z0-9]+\\.txt" markdown-mode))
  5. 按文本区域右下角的蓝色编辑按钮可通过 emacs 对其进行编辑。蓝色编辑按钮如下图所示:

    Screenshot of the blue edit button at the bottom right side of this textarea

    下面的屏幕截图是在 Markdown 模式下编辑这篇文章的 Emacs 缓冲区:

    Screenshot of an Emacs buffer in markdown-mode editing this post

  6. 在 Emacs 中完成编辑后,保存缓冲区以将其发送到 Firefox。

如果您希望其他域具有此功能,您需要更改上面的正则表达式。以下内容识别 Stack Exchange、Stack Overflow、Ask Ubuntu 和 Super User:

;; Integrate Emacs with Stack Exchange https://stackoverflow.com/a/10386560/789593
(add-to-list 'auto-mode-alist '("\\(stack\\(exchange\\|overflow\\)\\|superuser\\|askubuntu\\)\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))

将 markdown 模式与 Org 模式结合使用

要将 markdow 模式与 Org 模式一起使用,您可以使用 its feature for working with source code 。有了它,您可以在 Org 模式缓冲区中包含 Markdown block ,您可以通过 Markdown 模式进行编辑。您可以按如下方式使用它:

  1. 在组织模式缓冲区中输入 <s在换行符上并按 Tab。这将导致

    #+begin_src 

    #+end_src
  2. 输入markdown之后#+begin_src这样你就有了

    #+begin_src markdown

    #+end_src
  3. 在源代码块内(在 #+begin_src markdown#+end_src 之间)按 C-c ' 以使用 markdown 模式编辑源代码块。

  4. 以 markdown 模式编辑源代码块。

  5. C-c ' 返回组织模式缓冲区并插入编辑内容。这可能类似于以下屏幕截图所示:

    An Org-mode buffer editing a block of markdown code for this post

关于Stack Overflow 的 Markdown 的 Emacs 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10383986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com