commit dd9fd7b2d0a1321a5f85315b62d35df3500d111a
parent 21819a41d3f14226e96dddff8a48324297638b0a
Author: Tomas Hlavaty <tom@logand.com>
Date: Sun, 31 Jan 2021 23:44:17 +0100
handle abiword headings
Diffstat:
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/emacs-unoffice.el b/emacs-unoffice.el
@@ -72,7 +72,9 @@
(defun unoffice--to-txt (x)
(assert (eq 'unoffice (car x)))
- (fundamental-mode)
+ (outline-mode)
+ (insert "# -*- outline -*-\n")
+ (insert "\n")
(let (table)
(cl-labels ((ins (x)
(when (and x (not (equal "" x)))
@@ -110,7 +112,14 @@
(mapc #'rec (cdr x))
(setq table nil)
(org-table-align))
- (p
+ ((h1 h2 h3 h4 h5 h6 p)
+ (case (car x)
+ (h1 (insert "* "))
+ (h2 (insert "** "))
+ (h3 (insert "*** "))
+ (h4 (insert "**** "))
+ (h5 (insert "***** "))
+ (h6 (insert "****** ")))
(fill-previous x)
(mapc #'rec (cdr x))
(unless table
@@ -176,7 +185,14 @@
p1 nil
p2 nil)
(org-table-align))
- (p
+ ((h1 h2 h3 h4 h5 h6 p)
+ (case (car x)
+ (h1 (insert "* "))
+ (h2 (insert "** "))
+ (h3 (insert "*** "))
+ (h4 (insert "**** "))
+ (h5 (insert "***** "))
+ (h6 (insert "****** ")))
(mapc #'rec (cdr x))
(cl-shiftf p1 p2 (cdr x))
(unless table
@@ -213,7 +229,18 @@
(when align
(push align z))))
(mapc #'rec (cddr x))
- (push (cons 'p (nreverse p)) z)
+ (push (cons
+ (let ((style (xml-get-attribute x 'style)))
+ (cond
+ ((equal style "Heading 1") 'h1)
+ ((equal style "Heading 2") 'h2)
+ ((equal style "Heading 3") 'h3)
+ ((equal style "Heading 4") 'h4)
+ ((equal style "Heading 5") 'h5)
+ ((equal style "Heading 6") 'h6)
+ (t 'p)))
+ (nreverse p))
+ z)
(setq pp nil))
(c (mapc #'rec (cddr x)))
(t (mapc #'rec (cddr x))))))))