Solución a símbolos raros con org-mode y htmlize

2 minutos de lectura

A raíz de cambiar la forma de publicar en el blog observé que la exportación desde el modo org a html producía que htmlize insertara símbolos extraños al final de cada línea.

La solución la encontré en reddit, al parecer es un problema producido por el paquete fci, basta con instalar htmlize con la siguiente configuración

 1
 2(use-package htmlize
 3  :defer t
 4  :config
 5  (progn
 6
 7    ;; It is required to disable `fci-mode' when `htmlize-buffer' is called;
 8    ;; otherwise the invisible fci characters show up as funky looking
 9    ;; visible characters in the source code blocks in the html file.
10    ;; http://lists.gnu.org/archive/html/emacs-orgmode/2014-09/msg00777.html
11    (with-eval-after-load 'fill-column-indicator
12      (defvar modi/htmlize-initial-fci-state nil
13	"Variable to store the state of `fci-mode' when `htmlize-buffer' is called.")
14
15      (defun modi/htmlize-before-hook-fci-disable ()
16	(setq modi/htmlize-initial-fci-state fci-mode)
17	(when fci-mode
18	  (fci-mode -1)))
19
20      (defun modi/htmlize-after-hook-fci-enable-maybe ()
21	(when modi/htmlize-initial-fci-state
22	  (fci-mode 1)))
23
24      (add-hook 'htmlize-before-hook #'modi/htmlize-before-hook-fci-disable)
25      (add-hook 'htmlize-after-hook #'modi/htmlize-after-hook-fci-enable-maybe))
26
27    ;; `flyspell-mode' also has to be disabled because depending on the
28    ;; theme, the squiggly underlines can either show up in the html file
29    ;; or cause elisp errors like:
30    ;; (wrong-type-argument number-or-marker-p (nil . 100))
31    (with-eval-after-load 'flyspell
32      (defvar modi/htmlize-initial-flyspell-state nil
33	"Variable to store the state of `flyspell-mode' when `htmlize-buffer' is called.")
34
35      (defun modi/htmlize-before-hook-flyspell-disable ()
36	(setq modi/htmlize-initial-flyspell-state flyspell-mode)
37	(when flyspell-mode
38	  (flyspell-mode -1)))
39
40      (defun modi/htmlize-after-hook-flyspell-enable-maybe ()
41	(when modi/htmlize-initial-flyspell-state
42	  (flyspell-mode 1)))
43
44      (add-hook 'htmlize-before-hook #'modi/htmlize-before-hook-flyspell-disable)
45      (add-hook 'htmlize-after-hook #'modi/htmlize-after-hook-flyspell-enable-maybe))))

Tas la nueva instalación, los códigos desaparecen

Espero que te haya gustado, pasa un buen día.