簡體   English   中英

Emacs組織模式 - 導出到html而不使用語法高亮顯示

[英]Emacs org-mode - Export to html without syntax highlighting

我正在使用org-mode來寫博客文章(wordpress)。 因為我使用插件進行語法高亮,所以我不需要使用org-mode的語法高亮。

這是一個例子。

emacs中的來源。 在此輸入圖像描述

出口產出。 在此輸入圖像描述

當我刪除BEGIN_SRC之后的語言字段時,語法高亮也BEGIN_SRC了。 但我只想在導出時禁用語法高亮,而不刪除語言字段(emacs-lisp)。

我也在下面測試過,但它不起作用。

(setq org-src-fontify-natively t)

============更新============

我申請下面。 (謝謝@Picaud Vincent)(setq org-html-htmlize-output-type'nil)

它適用於沒有語言字段的源塊。 但它不適用於具有語言字段的源塊。

這是一個例子。

在.emacs文件..(setq org -html-htmlize-output-type'nil)

  1. 沒有語言領域的起源

 #+BEGIN_SRC (setq org-todo-keywords '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED"))) #+END_SRC 

出口

 <pre class="example"> (setq org-todo-keywords '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED"))) </pre> 

  1. 語言領域的起源

 #+BEGIN_SRC emacs-lisp (setq org-todo-keywords '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED"))) #+END_SRC 

出口

 <div class="org-src-container"> <pre class="src src-emacs-lisp"></pre> 

============更新============

最后,我找到了解決方案。

  1. 關注@Picaud Vincent的回答。 (setq org-html-htmlize-output-type nil)`

  2. 如果源塊中沒有帶語言字段的exports: code ,請將exports: code添加到語言字段。 ex> #+BEGIN_SRC emacs-lisp:exports code

雖然添加'exports:code`會禁用org-mode緩沖區中的語法高亮,但它解決了我的問題。

也許你可以嘗試自定義org-html-htmlize-output-type變量:

通常的HTML導出如下所示:

在此輸入圖像描述

但是,這個定制

(setq org-html-htmlize-output-type `nil)

你得到純文本:

在此輸入圖像描述

此變量和其他可自定義的變量在ox-html.el文件中定義。


更新:完整的html源代碼

之前:

<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span style="color: #a020f0;">defcustom</span> <span style="color: #a0522d;">org-html-htmlize-output-type</span> 'inline-css
  <span style="color: #8b2252;">"Output type to be used by htmlize when formatting code snippets.</span>
<span style="color: #8b2252;">Choices are `</span><span style="color: #008b8b;">css</span><span style="color: #8b2252;">' to export the CSS selectors only,`</span><span style="color: #008b8b;">inline-css</span><span style="color: #8b2252;">'</span>
<span style="color: #8b2252;">to export the CSS attribute values inline in the HTML or `</span><span style="color: #008b8b;">nil</span><span style="color: #8b2252;">' to</span>
<span style="color: #8b2252;">export plain text.  We use as default `</span><span style="color: #008b8b;">inline-css</span><span style="color: #8b2252;">', in order to</span>
<span style="color: #8b2252;">make the resulting HTML self-containing.</span>

<span style="color: #8b2252;">However, this will fail when using Emacs in batch mode for export, because</span>
<span style="color: #8b2252;">then no rich font definitions are in place.  It will also not be good if</span>
<span style="color: #8b2252;">people with different Emacs setup contribute HTML files to a website,</span>
<span style="color: #8b2252;">because the fonts will represent the individual setups.  In these cases,</span>
<span style="color: #8b2252;">it is much better to let Org/Htmlize assign classes only, and to use</span>
<span style="color: #8b2252;">a style file to define the look of these classes.</span>
<span style="color: #8b2252;">To get a start for your css file, start Emacs session and make sure that</span>
<span style="color: #8b2252;">all the faces you are interested in are defined, for example by loading files</span>
<span style="color: #8b2252;">in all modes you want.  Then, use the command</span>
<span style="color: #8b2252;">`\\[</span><span style="color: #008b8b;">org-html-htmlize-generate-css</span><span style="color: #8b2252;">]' to extract class definitions."</span>
  <span style="color: #483d8b;">:group</span> 'org-export-html
  <span style="color: #483d8b;">:type</span> '(choice (const css) (const inline-css) (const nil)))

(<span style="color: #a020f0;">defcustom</span> <span style="color: #a0522d;">org-html-htmlize-font-prefix</span> <span style="color: #8b2252;">"org-"</span>
  <span style="color: #8b2252;">"The prefix for CSS class names for htmlize font specifications."</span>
  <span style="color: #483d8b;">:group</span> 'org-export-html
  <span style="color: #483d8b;">:type</span> 'string)
</pre>
</div>

后:

<div class="org-src-container">
<pre class="src src-emacs-lisp">(defcustom org-html-htmlize-output-type 'inline-css
  "Output type to be used by htmlize when formatting code snippets.
Choices are `css' to export the CSS selectors only,`inline-css'
to export the CSS attribute values inline in the HTML or `nil' to
export plain text.  We use as default `inline-css', in order to
make the resulting HTML self-containing.

However, this will fail when using Emacs in batch mode for export, because
then no rich font definitions are in place.  It will also not be good if
people with different Emacs setup contribute HTML files to a website,
because the fonts will represent the individual setups.  In these cases,
it is much better to let Org/Htmlize assign classes only, and to use
a style file to define the look of these classes.
To get a start for your css file, start Emacs session and make sure that
all the faces you are interested in are defined, for example by loading files
in all modes you want.  Then, use the command
`\\[org-html-htmlize-generate-css]' to extract class definitions."
  :group 'org-export-html
  :type '(choice (const css) (const inline-css) (const nil)))

(defcustom org-html-htmlize-font-prefix "org-"
  "The prefix for CSS class names for htmlize font specifications."
  :group 'org-export-html
  :type 'string)
</pre>
</div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM