From 6bbf2084d783726e05a2e006ea2f79017adf50d9 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Fri, 12 Aug 2011 01:37:45 +0530 Subject: [PATCH] Prettify inlinetasks in odt and (x)html backends * lisp/org-inlinetask.el (org-inlinetask-export-templates): Fixed template for html so that the exported file is valid xhtml. Added template for odt. (org-inlinetask-export-handler): Fix typo in the regexp that trims content. Make sure that the content is flanked by paragraph boundaries on either side. * lisp/org-html.el (org-export-html-style-default): Add style for inlinetask. * contrib/lisp/org-xhtml.el (org-export-xhtml-style-default): Add style for inlinetask. * contrib/odt/styles/OrgOdtStyles.xml: Added following custom styles: OrgInlineTaskHeading and OrgInlineTaskFrame. * contrib/lisp/org-odt.el (org-odt-format-textbox) (org-odt-format-inlinetask): Added Refer following threads: 1. http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg00238.html 2. http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg00154.html Thanks to Suvayu Ali for reporting this issue and suggesting improvements. --- contrib/lisp/org-odt.el | 22 ++++++++++++++++++++++ contrib/lisp/org-xhtml.el | 6 ++++++ contrib/odt/styles/OrgOdtStyles.xml | 11 +++++++++++ lisp/org-html.el | 6 ++++++ lisp/org-inlinetask.el | 15 ++++++++++----- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 88d1068..848bba3 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1077,6 +1077,28 @@ MAY-INLINE-P allows inlining it as an image." (org-export-odt-do-format-image embed-as caption attr label size href)))) +(defun org-odt-format-textbox (text style) + (let ((draw-frame-pair + '("" . ""))) + (org-odt-format-tags + draw-frame-pair + (org-odt-format-tags + '("" . "") + text 0) style))) + +(defun org-odt-format-inlinetask (heading content + &optional todo priority tags) + (org-odt-format-stylized-paragraph + nil (org-odt-format-textbox + (concat (org-odt-format-stylized-paragraph + "OrgInlineTaskHeading" + (org-lparse-format + 'HEADLINE (concat (org-lparse-format-todo todo) " " heading) + nil tags)) + content) "OrgInlineTaskFrame"))) (defun org-export-odt-do-format-image (embed-as caption attr label size href) diff --git a/contrib/lisp/org-xhtml.el b/contrib/lisp/org-xhtml.el index 74ad64b..8a4a01f 100644 --- a/contrib/lisp/org-xhtml.el +++ b/contrib/lisp/org-xhtml.el @@ -166,6 +166,12 @@ not be modified." dt { font-weight: bold; } div.figure { padding: 0.5em; } div.figure p { text-align: center; } + div.inlinetask { + padding:10px; + border:2px solid gray; + margin:10px; + background: #ffffcc; + } textarea { overflow-x: auto; } .linenr { font-size:smaller } .code-highlighted {background-color:#ffff00;} diff --git a/contrib/odt/styles/OrgOdtStyles.xml b/contrib/odt/styles/OrgOdtStyles.xml index d7ec5ee..317a234 100644 --- a/contrib/odt/styles/OrgOdtStyles.xml +++ b/contrib/odt/styles/OrgOdtStyles.xml @@ -359,6 +359,17 @@ + + + + + + + + + + + diff --git a/lisp/org-html.el b/lisp/org-html.el index c150b3d..bc45d73 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -158,6 +158,12 @@ not be modified." dt { font-weight: bold; } div.figure { padding: 0.5em; } div.figure p { text-align: center; } + div.inlinetask { + padding:10px; + border:2px solid gray; + margin:10px; + background: #ffffcc; + } textarea { overflow-x: auto; } .linenr { font-size:smaller } .code-highlighted {background-color:#ffff00;} diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index 57ab505..0eb7361 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -107,11 +107,14 @@ When nil, they will not be exported." :type 'boolean) (defvar org-inlinetask-export-templates - '((html "
%s%s
%s
" + '((html "
%s%s
%s
" '((unless (eq todo "") (format "%s%s " class todo todo priority)) heading content)) + (odt "%s" '((org-odt-format-inlinetask heading content + todo priority tags))) + (latex "\\begin\{description\}\n\\item[%s%s]~%s\\end\{description\}" '((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority)) heading content)) @@ -349,12 +352,14 @@ Either remove headline and meta data, or do special formatting." ;; Ensure CONTENT has minimal indentation, a single ;; newline character at its boundaries, and isn't ;; protected. - (when (string-match "`\\([ \t]*\n\\)+" content) + (when (string-match "\\`\\([ \t]*\n\\)+" content) (setq content (substring content (match-end 0)))) (when (string-match "[ \t\n]+\\'" content) (setq content (substring content 0 (match-beginning 0)))) - (org-add-props (concat "\n" (org-remove-indentation content) "\n") - '(org-protected nil)))) + (org-add-props + (concat "\n\n" (org-remove-indentation content) "\n\n") + '(org-protected nil org-native-text nil)))) + (when (string-match org-complex-heading-regexp headline) (let* ((nil-to-str (function @@ -371,7 +376,7 @@ Either remove headline and meta data, or do special formatting." (backend-spec (assq org-export-current-backend org-inlinetask-export-templates)) (format-str (org-add-props (nth 1 backend-spec) - '(org-protected t))) + '(org-protected t org-native-text t))) (tokens (cadr (nth 2 backend-spec))) ;; Build export string. Ensure it won't break ;; surrounding lists by giving it arbitrary high -- 1.7.2.3