[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no syntax highlighting for code blocks with org-publish
From: |
Tim Cross |
Subject: |
Re: no syntax highlighting for code blocks with org-publish |
Date: |
Tue, 19 Jul 2022 07:50:47 +1000 |
User-agent: |
mu4e 1.8.6; emacs 29.0.50 |
"M. Pger" <mpger@protonmail.com> writes:
> Thank you for your answer. Here it is:
>
> 1. Create the following directory structure (3 directories):
> ~/test/
> ├── content
> ├── html
> └── .packages
>
> 2. Create the .el script to build the website (=~/test/build.el=):
>
> #+begin_src elisp
> ;; * Set the package installation directory (in order not to overwrite the
> standard ~/emacs.d)
> (require 'package)
> (setq package-user-dir (expand-file-name "./.packages"))
> (setq package-archives '(("melpa" . "https://melpa.org/packages/")))
> (add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/"))
>
> ;; * Initialize the package system
> (package-initialize)
> (unless package-archive-contents
> (package-refresh-contents))
>
> ;; * Install dependencies
> ;; ** since org is builtin, by default Emacs does not try to install the
> latest version from Elpa (9.5.4)
> ;; the following solves the issue:
> (defun mpger-ignore-builtin (pkg)
> (assq-delete-all pkg package--builtins)
> (assq-delete-all pkg package--builtin-versions))
> (mpger-ignore-builtin 'org)
> ;; ** install packages:
> (package-install 'org)
> (package-install 'htmlize)
>
> ;; * Load the publishing system:
> (require 'org)
> (require 'htmlize)
> (require 'ox-publish)
>
> ;; * Define the project
> (setq org-publish-project-alist
> (list
> (list "pages"
> :recursive t
> :htmlized-source t
> :base-directory "./content/"
> :base-extension "org"
> :publishing-directory "./html/"
> :publishing-function 'org-html-publish-to-html
> :with-creator t
> :with-toc t
> :section-numbers nil
> :time-stamp-file nil)
> ))
>
> ;; * Generate the site output
> (org-publish-all t)
>
> (message "Done!")
> #+end_src
>
>
> 3. In =~/test/content/=, create a simple test.org file to be published as
> html (=~/test/content/test.org=):
>
> #+begin_example
> * Here's some text
>
> Lorem ipsum.
>
> * Here's some code
>
> #+begin_src R :results output :exports both
> df <- mtcars ## a comment
> library(parallel)
> #+end_src
>
> #+end_example
>
> 4. Run =~/test/build.el= (e.g. with ~emacs -Q --script ~/test/build.el~) and
> compare with
> the output from ~C-c C-e h o~. The latter has syntax highlighting, the former
> has not.
>
Just a shot in the dark. Does syntax highlighting work if the source
block is something like emacs-lisp rather than R?
I know that syntax highlighting is based on the syntax highlighting from
the mode used for a specific language. I'm wondering if your not getting
syntax highlighting because in yhour publish script, R mode is not
loaded, but when you open the org file and do a 'normal' export, R is
loaded and so you get syntax highlighting. Therefore, I would try the
same experiment, but instead of a source block of R code, I would try a
source block of emacs-lisp code as we know that emacs-lisp mode will be
loaded.
Could be completely off track though!
- no syntax highlighting for code blocks with org-publish, M. Pger, 2022/07/17
- Re: no syntax highlighting for code blocks with org-publish, Ihor Radchenko, 2022/07/17
- Re: no syntax highlighting for code blocks with org-publish, M. Pger, 2022/07/18
- Re: no syntax highlighting for code blocks with org-publish,
Tim Cross <=
- Re: no syntax highlighting for code blocks with org-publish, M. Pger, 2022/07/18
- Re: no syntax highlighting for code blocks with org-publish, Tim Cross, 2022/07/19
- Re: no syntax highlighting for code blocks with org-publish, M. Pger, 2022/07/19
- Re: no syntax highlighting for code blocks with org-publish, Tim Cross, 2022/07/19
- Re: no syntax highlighting for code blocks with org-publish, M. Pger, 2022/07/19
- Re: no syntax highlighting for code blocks with org-publish, M. Pger, 2022/07/20
- Re: no syntax highlighting for code blocks with org-publish, Ihor Radchenko, 2022/07/21