Patchwork [O,odt] htmlfontify + Support for src blockfontification

login
register
Submitter Jambunathan K
Date 2011-08-19 12:26:24
Message ID <81liupk2of.fsf@gmail.com>
Download mbox | patch
Permalink /patch/896/
State New
Headers show

Comments

Jambunathan K - 2011-08-19 12:26:24
> Hi Jambunathan,
>
> we are discussing in abstract terms, and that might distract us from
> DTRT together: can you show the patched version of htmlfontify.el?

Here you go.

Patch numbered 1 is the base htmlfontify.el (same as that in emacs-24
trunk). I am also attaching a final copy of htmlfontify.el after it has
gone through the series of 5 patches.

Jambunathan K.

--
Jambunathan K - 2011-08-19 12:49:04
Jambunathan K <kjambunathan@gmail.com> writes:

>> Hi Jambunathan,
>>
>> we are discussing in abstract terms, and that might distract us from
>> DTRT together: can you show the patched version of htmlfontify.el?
>
> Here you go.
>
> Patch numbered 1 is the base htmlfontify.el (same as that in emacs-24
> trunk). I am also attaching a final copy of htmlfontify.el after it has
> gone through the series of 5 patches.

Sample test.org file to quickly understand the nature of changes. A line
by line comparison will show how patches add up.

> Jambunathan K.

--
Bastien Guerry - 2011-08-19 21:48:53
Jambunathan K <kjambunathan@gmail.com> writes:

>> we are discussing in abstract terms, and that might distract us from
>> DTRT together: can you show the patched version of htmlfontify.el?
>
> Here you go.

Thanks.  

I will look into this next week.  Not before tuesday, as I'm off 
for a long week-end.

Best,

Patch

From e6908d75832dc3cbc8573119a5b32d9a66c90a6f Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Fri, 19 Aug 2011 01:50:23 +0530
Subject: [PATCH 6/6] htmlfontify.el: Add htmlfontify-string & fix a bug in fontification

* contrib/lisp/htmlfontify.el (htmlfontify-string): New defun.
(hfy-compile-face-map): Make sure that the last char in the buffer is
correctly fontified.
---
 contrib/lisp/htmlfontify.el |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/contrib/lisp/htmlfontify.el b/contrib/lisp/htmlfontify.el
index 6a4d62f..5b86d98 100755
--- a/contrib/lisp/htmlfontify.el
+++ b/contrib/lisp/htmlfontify.el
@@ -1448,7 +1448,7 @@  Returns a modified copy of FACE-MAP."
         (setq pt (next-char-property-change pt))
         (setq pt-narrow (+ offset pt)))
       (if (and map (not (eq 'end (cdar map))))
-          (push (cons (- (point-max) (point-min)) 'end) map)))
+          (push (cons (1+ (- (point-max) (point-min))) 'end) map)))
     (if (hfy-opt 'merge-adjacent-tags) (hfy-merge-adjacent-spans map) map)))
 
 (defun hfy-buffer ()
@@ -1792,6 +1792,21 @@  FILE, if set, is the file name."
     (set-buffer-modified-p nil)
     html-buffer))
 
+(defun htmlfontify-string (string)
+  "Take a STRING and return a fontified version of it.
+It is assumed that STRING has text properties that allow it to be
+fontified.  This is a simple convenience wrapper around
+`htmlfontify-buffer'."
+  (let* ((hfy-optimisations-1 (copy-list hfy-optimisations))
+	 (hfy-optimisations (add-to-list 'hfy-optimisations-1
+					 'skip-refontification)))
+    (with-temp-buffer
+      (insert string)
+      (htmlfontify-buffer)
+      (prog1 (buffer-string)
+	(setq buffer-modified-p nil)
+	(kill-buffer)))))
+
 (defun hfy-force-fontification ()
   "Try to force font-locking even when it is optimized away."
   (run-hooks 'hfy-init-kludge-hook)
-- 
1.7.2.3