[ Please include me in the replies, as I'm not subscribed to emacs-orgmode. ]

> > Your patch may work in this particular case, but the idea behind
> > htmlize is to describe the state of the buffer.  If a property ends
> > after the newline, it is intended that the generated HTML reflect
> 
> The philosophical question is then: Is the newline character part of the 
> syntax construct that is being fontified, or rather a "formatting code" 
> that should be kept separate?

htmlize doesn't operate on the level of syntax-based fontification, it
examines the display-related properties attached to buffer text (not
necessarily by font-lock) and renders them into the corresponding HTML.

If a display property includes the newline character, that will be
reflected in the HTML.  This works fine for displaying in a browser, but
confuses org-mode's post-processing of HTML, which (if my understanding
is correct) assumes that spans will be closed before the newline.  This
assumption is wrong in the case you present.

However, using htmlize-before-hook, it is trivial to make the assumption
correct by resetting the property.  Here is your example, modified to do
so:

(let ((filename (expand-file-name "foo.org" temporary-file-directory)))
   (switch-to-buffer (find-file-noselect filename))
   (erase-buffer)
   (insert "*
#+BEGIN_SRC emacs-lisp
(let ((x 42)) ; meaning of l.u.e.
   (print x))  ; (ref:2)
#+END_SRC")
   (save-buffer)
   (org-mode)
   (let ((htmlize-before-hook htmlize-before-hook))
     (add-hook 'htmlize-before-hook
               (lambda ()
                 (goto-char (point-min))
                 (while (progn (end-of-line) (not (eobp)))
                   (put-text-property (point) (1+ (point)) 'face nil)
                   (forward-char 1))))
     (org-export-as-html nil)))

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to