0

I got some source blocks in my org document like this one:

#+BEGIN_SRC ipython
print("Hola")
#+END_SRC

When the org file is exported to html (and only to html) I got weird symbols at the end of each line:

print("Hola") 

Any ideas why this is happening?

  • What's the coding system for the buffer you're saving? C-h C nil to find out. Also, what line endings are you using. Are there any extra characters (as far as you can tell) after the closing )? Can you open the html file and view in hexl-mode to see what characters those  are? – Marty Neal Aug 28 '18 at 2:24
  • Thanks for your comment, the buffer is utf-8. The characters added at the end (in the html file) are &#57344;&#57345;&#57345; e.g.: <span style="color: #51afef;">import</span> seaborn <span style="color: #51afef;">as</span> sns&#57344;&#57345;&#57345; – nanounanue Aug 29 '18 at 22:00
0

Apparently the culprit is the fci package. A working solution was posted here

For completeness I am copying the code here, but all the credit should go to the author of the gist, @kaushalmodi. Just add this to your .emacs file.

(use-package htmlize
 :defer t
  :config
  (progn

    ;; It is required to disable `fci-mode' when `htmlize-buffer' is called;
    ;; otherwise the invisible fci characters show up as funky looking
    ;; visible characters in the source code blocks in the html file.
    ;; http://lists.gnu.org/archive/html/emacs-orgmode/2014-09/msg00777.html
    (with-eval-after-load 'fill-column-indicator
      (defvar modi/htmlize-initial-fci-state nil
        "Variable to store the state of `fci-mode' when `htmlize-buffer' is called.")

      (defun modi/htmlize-before-hook-fci-disable ()
        (setq modi/htmlize-initial-fci-state fci-mode)
        (when fci-mode
          (fci-mode -1)))

      (defun modi/htmlize-after-hook-fci-enable-maybe ()
        (when modi/htmlize-initial-fci-state
          (fci-mode 1)))

      (add-hook 'htmlize-before-hook #'modi/htmlize-before-hook-fci-disable)
      (add-hook 'htmlize-after-hook #'modi/htmlize-after-hook-fci-enable-maybe))

    ;; `flyspell-mode' also has to be disabled because depending on the
    ;; theme, the squiggly underlines can either show up in the html file
    ;; or cause elisp errors like:
    ;; (wrong-type-argument number-or-marker-p (nil . 100))
    (with-eval-after-load 'flyspell
      (defvar modi/htmlize-initial-flyspell-state nil
        "Variable to store the state of `flyspell-mode' when `htmlize-buffer' is called.")

      (defun modi/htmlize-before-hook-flyspell-disable ()
        (setq modi/htmlize-initial-flyspell-state flyspell-mode)
        (when flyspell-mode
          (flyspell-mode -1)))

      (defun modi/htmlize-after-hook-flyspell-enable-maybe ()
        (when modi/htmlize-initial-flyspell-state
          (flyspell-mode 1)))

      (add-hook 'htmlize-before-hook #'modi/htmlize-before-hook-flyspell-disable)
(add-hook 'htmlize-after-hook #'modi/htmlize-after-hook-flyspell-enable-maybe))))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.