emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug: Export to html inserts strange unicode characters at line break


From: Kaushal
Subject: [O] Bug: Export to html inserts strange unicode characters at line breaks because of fci-mode [8.2.7c (8.2.7c-64-g01f736-elpa @ /home/kmodi/.emacs.d/elpa/org-20140915/)]
Date: Thu, 25 Sep 2014 15:50:59 -0400

Hi all,

I have fci-mode installed and enabled for programming modes.

When org exports to html, htmlize figures out the syntax highlighting of
the code by calling  =(funcall lang-mode)=. 

That activates =fci-mode=. 

=fci-mode= shows the fill column using a unicode character. The issue is
that org export to html exports that character as well.

Those characters show up in html as below!

So the solution is to fix the =orx-html-fontify-code= function.

I have modified the function as below; my edits are just those 2 lines
added to the function. The 2 lines simply check if fci-mode is installed. If installed it disables fci mode. Even if the package is not installed, no error will be raised.

It will be great if this edit can be incorporated into the org source
code.

Thank you.



(defun org-html-fontify-code (code lang)
  "Color CODE with htmlize library.
CODE is a string representing the source code to colorize.  LANG
is the language used for CODE, as a string, or nil."
  (when code
    (cond
     ;; Case 1: No lang.  Possibly an example block.
     ((not lang)
      ;; Simple transcoding.
      (org-html-encode-plain-text code))
     ;; Case 2: No htmlize or an inferior version of htmlize
     ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
      ;; Emit a warning.
      (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
      ;; Simple transcoding.
      (org-html-encode-plain-text code))
     (t
      ;; Map language
      (setq lang (or (assoc-default lang org-src-lang-modes) lang))
      (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
(cond
;; Case 1: Language is not associated with any Emacs mode
((not (functionp lang-mode))
 ;; Simple transcoding.
 (org-html-encode-plain-text code))
;; Case 2: Default.  Fontify code.
(t
 ;; htmlize
 (setq code (with-temp-buffer
      ;; Switch to language-specific mode.
      (funcall lang-mode)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                       (when (require 'fill-column-indicator nil 'noerror)
                         (fci-mode -1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

      (insert code)
      ;; Fontify buffer.
      (font-lock-fontify-buffer)
      ;; Remove formatting on newline characters.
      (save-excursion
(let ((beg (point-min))
      (end (point-max)))
  (goto-char beg)
  (while (progn (end-of-line) (< (point) end))
    (put-text-property (point) (1+ (point)) 'face nil)
    (forward-char 1))))
      (org-src-mode)
      (set-buffer-modified-p nil)
      ;; Htmlize region.
      (org-html-htmlize-region-for-paste
(point-min) (point-max))))
 ;; Strip any enclosing <pre></pre> tags.
 (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
(end (and beg (string-match "</pre>\\'" code))))
   (if (and beg end) (substring code beg end) code)))))))))



Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See


Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------



Emacs  : GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.10.4)
 of 2014-01-21 
Package: Org-mode version 8.2.7c (8.2.7c-64-g01f736-elpa @ /home/kmodi/.emacs.d/elpa/org-20140915/)

current state:
==============
(setq
 org-src-lang-modes '(("dot" . graphviz-dot) ("systemverilog" . verilog) ("ocaml" . tuareg) ("elisp" . emacs-lisp)
                      ("ditaa" . artist) ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql)
                      ("calc" . fundamental) ("C" . c) ("cpp" . c++) ("C++" . c++) ("screen" . shell-script))
 org-hide-leading-stars t
 org-latex-default-figure-position "H"
 org-reveal-mathjax t
 org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe
                      org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-html-format-drawer-function '(lambda (name contents) contents)
 org-log-done 'timestamp
 org-latex-minted-options '(("linenos") ("numbersep" "5pt") ("frame" "none") ("framesep" "2mm"))
 org-latex-format-inlinetask-function 'ignore
 org-confirm-shell-link-function 'yes-or-no-p
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-startup-folded 'showeverything
 org-latex-pdf-process '("xelatex -shell-escape %f" "xelatex -shell-escape %f" "xelatex -shell-escape %f")
 org-pretty-entities t
 org-use-sub-superscripts '{}
 org-export-with-sub-superscripts '{}
 org-return-follows-link t
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-todo-keyword-faces '(("TODO" . org-warning) ("SOMEDAY" . "#FFEF9F")
                          ("CANCELED" :foreground "#94BFF3" :weight bold :strike-through t))
 org-capture-templates '(("t" "Project 1 Meeting Notes" entry
                          (file+datetree (concat project1-org-dir "/dv_meeting_notes.org"))
                          "\n* %?\n  Entered on %U")
                         ("j" "Journal" entry (file+datetree (concat org-directory "/journal.org"))
                          "\n* %?\n  Entered on %U")
                         ("n" "Note" entry (file (concat org-directory "/notes.org"))
                          "\n* %?\n  Context:\n    %i\n  Entered on %U")
                         ("u" "UVM/System Verilog Notes" entry (file (concat org-directory "/uvm.org"))
                          "\n* %?\n  Context:\n    %i\n  Entered on %U")
                         )
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-format-drawer-function '(lambda (name contents) contents)
 org-from-is-user-regexp "\\<Kaushal\\.Modi\\>"
 org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-pretty-entities-include-sub-superscripts nil
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(turn-on-flyspell wrap-region-mode turn-on-stripe-table-mode fci-mode er/add-org-mode-expansions
                 #[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook org-show-block-all append local] 5]
                 #[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes turn-on-visual-line-mode)
 org-agenda-skip-comment-trees nil
 org-use-speed-commands t
 org-ascii-format-drawer-function '(lambda (name contents width) contents)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe)
 org-directory "/home/kmodi/org"
 org-enforce-todo-dependencies t
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-hide-inline-tasks
                  org-cycle-show-empty-lines org-optimize-window-after-visibility-change)
 org-plantuml-jar-path "/home/kmodi/.emacs.d/plantuml/plantuml.7999.jar"
 org-confirm-elisp-link-not-regexp "\\(.*switch\\-to\\-buffer.*\\|org-show\\)"
 org-export-before-processing-hook '(endless/update-includes)
 org-latex-create-formula-image-program 'imagemagick
 org-blank-before-new-entry '((heading) (plain-list-item))
 org-todo-keywords '((sequence "TODO" "SOMEDAY" "CANCELED" "DONE"))
 org-latex-packages-alist '(("" "parskip") ("" "minted") ("" "tikz") ("section" "placeins") ("mathscr" "eucal")
                            ("" "latexsym") ("" "float") ("" "caption"))
 org-babel-tangle-lang-exts '(("latex" . "tex") ("emacs-lisp" . "el"))
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-latex-listings 'minted
 org-ditaa-jar-path "/home/kmodi/.emacs.d/ditaa/ditaa0_9.jar"
 org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
 org-html-format-headline-function 'ignore
 org-export-with-smart-quotes t
 org-completion-use-ido t
 org-babel-load-languages '((ditaa . t) (plantuml . t) (latex . t) (dot . t))
 org-html-format-inlinetask-function 'ignore
 org-agenda-mode-hook '((lambda nil (define-key org-agenda-mode-map "x" (quote sacha/org-agenda-done))
                         (define-key org-agenda-mode-map "X" (quote sacha/org-agenda-mark-done-and-add-followup))
                         (define-key org-agenda-mode-map "N" (quote sacha/org-agenda-new)))
                        )
 org-agenda-files "/home/kmodi/org/agenda.files"
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate
 org-src-fontify-natively t
 )


--
Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]