求助, org 文件使用 emacs script 执行 org-publish-all 的时候代码块没有高亮? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
gridsah
V2EX    Emacs

求助, org 文件使用 emacs script 执行 org-publish-all 的时候代码块没有高亮?

  •  
  •   gridsah 2022-04-29 22:47:09 +08:00 1497 次点击
    这是一个创建于 1260 天前的主题,其中的信息可能已经有所发展或是发生改变。

    一个有点奇怪的问题。我在 emacs 里用 M-x lsz/org-export-publish Ret 执行导出的时候,代码块是可以正常高亮的。但一旦使用 emacs --script ~/.emacs.d/lisp/script-org-export-publish.el 来导出,代码块的高亮就没了

    (use-package htmlize) (use-package org :hook ('before-save . 'lsz/org-mode-hook-func-before-save) :config (setq org-startup-truncated nil) (setq org-support-shift-select t) (setq org-use-sub-superscripts '{}) (setq org-use-fast-todo-selection t) (setq org-todo-keywords '((sequence "TODO(t)" "DOING(i)" "|" "DONE(d)" "ABORT(a)"))) ) (use-package ox-html :ensure org :config (setq org-html-htmlize-output-type 'inline-css) (setq org-src-fontify-natively t) ) (defun lsz/org-export-publish() "Publish org site by publish script." (interactive) (load "~/.emacs.d/lisp/script-org-export-publish.el")) (use-package ox-publish :ensure org :config ;; (setq org-html-postamble t) ;; (setq org-html-postamble-format '(("en" ""))) (setq org-export-with-sub-superscripts '{}) (setq org-publish-project-alist (let* ((lsz/site-path "~/Documents/LSZOrgArticle/") (lsz/site-pub-path "~/Documents/LSZOrgArticlePublish/") (get-content (lambda (x) (with-temp-buffer (insert-file-contents (concat lsz/site-path x)) (buffer-string)))) (lsz/site-postamble (funcall get-content "template/postamble.html")) (lsz/site-preamble (funcall get-content "template/preamble.html")) (lsz/site-head (funcall get-content "template/head.html"))) `( ("blog" :base-directory ,(concat lsz/site-path "article/blog/") :base-extension "org" :publishing-directory ,(concat lsz/site-pub-path "article/blog/") :publishing-function org-html-publish-to-html :recursive t :headline-levels 4 :auto-sitemap t :sitemap-filename "sitemap-index.org" :sitemap-title "blog" :html-doctype "html5" :html-head ,lsz/site-head :html-preamble ,lsz/site-preamble :html-postamble ,lsz/site-postamble :htmlized-source t :with-toc t ) ("reading" :base-directory ,(concat lsz/site-path "article/reading/") :base-extension "org" :publishing-directory ,(concat lsz/site-pub-path "article/reading/") :publishing-function org-html-publish-to-html :recursive t :headline-levels 4 :auto-sitemap t :sitemap-filename "sitemap-index.org" :sitemap-title "reading" :html-doctype "html5" :html-head ,lsz/site-head :html-preamble ,lsz/site-preamble :html-postamble ,lsz/site-postamble :htmlized-source t :with-toc t ) ("wiki" :base-directory ,(concat lsz/site-path "article/wiki/") :base-extension "org" :publishing-directory ,(concat lsz/site-pub-path "article/wiki/") ;; :publishing-function org-html-publish-to-html :recursive t :headline-levels 4 :auto-sitemap t :sitemap-filename "sitemap-index.org" :sitemap-title "wiki" ;; :html-doctype "html5" :html-head ,lsz/site-head :html-preamble ,lsz/site-preamble :html-postamble ,lsz/site-postamble ;; :htmlized-source t :with-toc t ) ("site" :base-directory ,(concat lsz/site-path "article/site/") :base-extension "org" :publishing-directory ,(concat lsz/site-pub-path "article/site/") :publishing-function org-html-publish-to-html :recursive t :headline-levels 4 :html-doctype "html5" :html-head ,lsz/site-head :html-preamble ,lsz/site-preamble :html-postamble ,lsz/site-postamble :htmlized-source t :with-toc nil ) ("static" :base-directory ,(concat lsz/site-path "article_static/") :base-extension "css\\|js\\|png\\|jpg\\|gif\\|zip\\|7z\\|rar\\|pdf" :publishing-directory ,(concat lsz/site-pub-path "/article_static") :publishing-function org-publish-attachment :recursive t ) ("all" :components ("blog" "reading" "wiki" "site" "static")) )))) 

    这是 ~/.emacs.d/lisp/script-org-export-publish.el

    ;;; need environment (package-initialize) (load "~/.emacs.d/init.el") ;;; publish file (org-publish-all) 

    这是正常渲染出来的,有代码高亮的 html

    <pre class="src src-python"><span style="color: #a020f0;">import</span> csv <span style="color: #a020f0;">with</span> <span style="color: #483d8b;">open</span>(<span style="color: #8b2252;">'stock.csv'</span>,<span style="color: #8b2252;">'r'</span>) <span style="color: #a020f0;">as</span> fp: <span style="color: #a0522d;">reader</span> = csv.reader(fp) <span style="color: #a0522d;">titles</span> = <span style="color: #483d8b;">next</span>(reader) <span style="color: #a020f0;">for</span> x <span style="color: #a020f0;">in</span> reader: <span style="color: #a020f0;">print</span>(x) </pre> 

    这是 emacs --script 渲染出来的 html:

    <pre class="src src-python"><span style="font-weight: bold;">import</span> csv <span style="font-weight: bold;">with</span> <span style="font-weight: bold;">open</span>(<span style="font-style: italic;">'stock.csv'</span>,<span style="font-style: italic;">'r'</span>) <span style="font-weight: bold;">as</span> fp: <span style="font-weight: bold; font-style: italic;">reader</span> = csv.reader(fp) <span style="font-weight: bold; font-style: italic;">titles</span> = <span style="font-weight: bold;">next</span>(reader) <span style="font-weight: bold;">for</span> x <span style="font-weight: bold;">in</span> reader: <span style="font-weight: bold;">print</span>(x) </pre> 

    效果图在 https://emacs-china.org/t/org-emacs-script-org-publish-all/20782

    老哥们啊,这是咋回事,该从哪下手排查问题,我 google 了几个小时完全没有头绪。

    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5341 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 09:15 PVG 17:15 LAX 02:15 JFK 05:15
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86