From: Carsten Dominik <carsten.dominik@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Thorsten Jolitz <tjolitz@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: SUMMARY: [Feature Request] Make property-drawers exportable
Date: Thu, 26 Sep 2013 13:28:15 +0200 [thread overview]
Message-ID: <58B8BF7F-E4B4-405F-8EC1-E73821BE7B18@gmail.com> (raw)
In-Reply-To: <87pprwzkjx.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 19008 bytes --]
Hi,
this does look good to me, except that the customize type of
org-export-with-properties needs to be extended to allow for the
list of strings.
Please just go ahead and apply it to master, then I and hopefully others will test it further.
- Carsten
On 25.9.2013, at 22:57, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> Not really. It would simplify processing to have the list instead
>> of a string, but indeed, a filter can accomplish all of it.
>
> Here is a first patch. It doesn't handle export back-ends in contrib.
>
>
> Regards,
>
> --
> Nicolas Goaziou
> From c48974d10e0d57b6332fcfed384a49ee530ea04a Mon Sep 17 00:00:00 2001
> From: Nicolas Goaziou <n.goaziou@gmail.com>
> Date: Wed, 25 Sep 2013 21:27:29 +0200
> Subject: [PATCH] ox: Add a defcustom to export properties drawers
>
> * lisp/ox.el (org-export-with-drawers): Improve docstring.
> (org-export-with-properties): New variable
> (org-export--skip-p): Handle new variable.
> (org-export-options-alist): Install new variable.
> * lisp/ox-ascii.el (org-ascii-node-property,
> org-ascii-property-drawer): New functions.
> * lisp/ox-html.el (org-html-node-property): New function.
> (org-html-property-drawer): Export property drawers as "pre" blocks.
> * lisp/ox-latex.el (org-latex-property-drawer,
> org-latex-node-property): New functions.
> * lisp/ox-man.el (org-man-node-property, org-man-property-drawer): New
> functions.
> * lisp/ox-md.el (org-md-node-property, org-md-property-drawer): New
> functions.
> * lisp/ox-odt.el (org-odt-node-property): New function.
> (org-odt-property-drawer): Export property drawers as fixed width
> blocks.
> * lisp/ox-texinfo.el (org-texinfo-node-property): New function.
> (org-texinfo-property-drawer): Export property drawers as verbatim
> blocks.
> * testing/lisp/test-ox.el: Add tests.
> ---
> lisp/ox-ascii.el | 23 +++++++++++++++++++++++
> lisp/ox-html.el | 21 ++++++++++++++++-----
> lisp/ox-latex.el | 25 ++++++++++++++++++++++++-
> lisp/ox-man.el | 19 ++++++++++++++++++-
> lisp/ox-md.el | 24 ++++++++++++++++++++++++
> lisp/ox-odt.el | 23 ++++++++++++++++++-----
> lisp/ox-texinfo.el | 21 ++++++++++++++++-----
> lisp/ox.el | 28 +++++++++++++++++++++++++---
> testing/lisp/test-ox.el | 19 +++++++++++++++++++
> 9 files changed, 183 insertions(+), 20 deletions(-)
>
> diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
> index 74a7c64..e0a3fa9 100644
> --- a/lisp/ox-ascii.el
> +++ b/lisp/ox-ascii.el
> @@ -81,10 +81,12 @@
> (latex-fragment . org-ascii-latex-fragment)
> (line-break . org-ascii-line-break)
> (link . org-ascii-link)
> + (node-property . org-ascii-node-property)
> (paragraph . org-ascii-paragraph)
> (plain-list . org-ascii-plain-list)
> (plain-text . org-ascii-plain-text)
> (planning . org-ascii-planning)
> + (property-drawer . org-ascii-property-drawer)
> (quote-block . org-ascii-quote-block)
> (quote-section . org-ascii-quote-section)
> (radio-target . org-ascii-radio-target)
> @@ -1440,6 +1442,18 @@ INFO is a plist holding contextual information."
> (unless org-ascii-links-to-notes (format " (%s)" raw-link))))))))
>
>
> +;;;; Node Properties
> +
> +(defun org-ascii-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element from Org to ASCII.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) ""))))
> +
> +
> ;;;; Paragraph
>
> (defun org-ascii-paragraph (paragraph contents info)
> @@ -1509,6 +1523,15 @@ channel."
> " "))
>
>
> +;;;; Property Drawer
> +
> +(defun org-ascii-property-drawer (property-drawer contents info)
> + "Transcode a PROPERTY-DRAWER element from Org to ASCII.
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (org-string-nw-p contents))
> +
> +
> ;;;; Quote Block
>
> (defun org-ascii-quote-block (quote-block contents info)
> diff --git a/lisp/ox-html.el b/lisp/ox-html.el
> index 14b31b2..66862bc 100644
> --- a/lisp/ox-html.el
> +++ b/lisp/ox-html.el
> @@ -76,6 +76,7 @@
> (latex-fragment . org-html-latex-fragment)
> (line-break . org-html-line-break)
> (link . org-html-link)
> + (node-property . org-html-node-property)
> (paragraph . org-html-paragraph)
> (plain-list . org-html-plain-list)
> (plain-text . org-html-plain-text)
> @@ -2782,6 +2783,17 @@ INFO is a plist holding contextual information. See
> ;; No path, only description. Try to do something useful.
> (t (format "<i>%s</i>" desc)))))
>
> +;;;; Node Property
> +
> +(defun org-html-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element from Org to HTML.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) ""))))
> +
> ;;;; Paragraph
>
> (defun org-html-paragraph (paragraph contents info)
> @@ -2930,11 +2942,10 @@ channel."
>
> (defun org-html-property-drawer (property-drawer contents info)
> "Transcode a PROPERTY-DRAWER element from Org to HTML.
> -CONTENTS is nil. INFO is a plist holding contextual
> -information."
> - ;; The property drawer isn't exported but we want separating blank
> - ;; lines nonetheless.
> - "")
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (and (org-string-nw-p contents)
> + (format "<pre class=\"example\">\n%s</pre>" contents)))
>
> ;;;; Quote Block
>
> diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
> index e1173ef..196e50f 100644
> --- a/lisp/ox-latex.el
> +++ b/lisp/ox-latex.el
> @@ -63,11 +63,12 @@
> (latex-fragment . org-latex-latex-fragment)
> (line-break . org-latex-line-break)
> (link . org-latex-link)
> + (node-property . org-latex-node-property)
> (paragraph . org-latex-paragraph)
> (plain-list . org-latex-plain-list)
> (plain-text . org-latex-plain-text)
> (planning . org-latex-planning)
> - (property-drawer . (lambda (&rest args) ""))
> + (property-drawer . org-latex-property-drawer)
> (quote-block . org-latex-quote-block)
> (quote-section . org-latex-quote-section)
> (radio-target . org-latex-radio-target)
> @@ -1837,6 +1838,18 @@ INFO is a plist holding contextual information. See
> (t (format org-latex-link-with-unknown-path-format desc)))))
>
>
> +;;;; Node Property
> +
> +(defun org-latex-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element from Org to LaTeX.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) ""))))
> +
> +
> ;;;; Paragraph
>
> (defun org-latex-paragraph (paragraph contents info)
> @@ -1961,6 +1974,16 @@ information."
> "\\\\"))
>
>
> +;;;; Property Drawer
> +
> +(defun org-latex-property-drawer (property-drawer contents info)
> + "Transcode a PROPERTY-DRAWER element from Org to LaTeX.
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (and (org-string-nw-p contents)
> + (format "\\begin{verbatim}\n%s\\end{verbatim}" contents)))
> +
> +
> ;;;; Quote Block
>
> (defun org-latex-quote-block (quote-block contents info)
> diff --git a/lisp/ox-man.el b/lisp/ox-man.el
> index a160e4c..760e264 100644
> --- a/lisp/ox-man.el
> +++ b/lisp/ox-man.el
> @@ -76,11 +76,12 @@
> (keyword . org-man-keyword)
> (line-break . org-man-line-break)
> (link . org-man-link)
> + (node-property . org-man-node-property)
> (paragraph . org-man-paragraph)
> (plain-list . org-man-plain-list)
> (plain-text . org-man-plain-text)
> (planning . org-man-planning)
> - (property-drawer . (lambda (&rest args) ""))
> + (property-drawer . org-man-property-drawer)
> (quote-block . org-man-quote-block)
> (quote-section . org-man-quote-section)
> (radio-target . org-man-radio-target)
> @@ -663,6 +664,16 @@ INFO is a plist holding contextual information. See
> ;; No path, only description. Try to do something useful.
> (t (format "\\fI%s\\fP" desc)))))
>
> +;;;; Node Property
> +
> +(defun org-man-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element from Org to Man.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) ""))))
>
> ;;; Paragraph
>
> @@ -722,6 +733,12 @@ contextual information."
>
> ;;; Property Drawer
>
> +(defun org-man-property-drawer (property-drawer contents info)
> + "Transcode a PROPERTY-DRAWER element from Org to Man.
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (and (org-string-nw-p contents)
> + (format ".RS\n.nf\n%s\n.fi\n.RE" contents)))
>
> ;;; Quote Block
>
> diff --git a/lisp/ox-md.el b/lisp/ox-md.el
> index feb611c..1114c50 100644
> --- a/lisp/ox-md.el
> +++ b/lisp/ox-md.el
> @@ -82,9 +82,11 @@ This variable can be set to either `atx' or `setext'."
> (item . org-md-item)
> (line-break . org-md-line-break)
> (link . org-md-link)
> + (node-property . org-md-node-property)
> (paragraph . org-md-paragraph)
> (plain-list . org-md-plain-list)
> (plain-text . org-md-plain-text)
> + (property-drawer . org-md-property-drawer)
> (quote-block . org-md-quote-block)
> (quote-section . org-md-example-block)
> (section . org-md-section)
> @@ -334,6 +336,18 @@ a communication channel."
> (format "[%s](%s)" contents path)))))))
>
>
> +;;;; Node Property
> +
> +(defun org-md-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element into Markdown syntax.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) ""))))
> +
> +
> ;;;; Paragraph
>
> (defun org-md-paragraph (paragraph contents info)
> @@ -382,6 +396,16 @@ contextual information."
> text)
>
>
> +;;;; Property Drawer
> +
> +(defun org-md-property-drawer (property-drawer contents info)
> + "Transcode a PROPERTY-DRAWER element into Markdown format.
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (and (org-string-nw-p contents)
> + (replace-regexp-in-string "^" " " contents)))
> +
> +
> ;;;; Quote Block
>
> (defun org-md-quote-block (quote-block contents info)
> diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
> index ae9e473..57a9b6e 100644
> --- a/lisp/ox-odt.el
> +++ b/lisp/ox-odt.el
> @@ -59,6 +59,7 @@
> (latex-fragment . org-odt-latex-fragment)
> (line-break . org-odt-line-break)
> (link . org-odt-link)
> + (node-property . org-odt-node-property)
> (paragraph . org-odt-paragraph)
> (plain-list . org-odt-plain-list)
> (plain-text . org-odt-plain-text)
> @@ -2868,6 +2869,18 @@ INFO is a plist holding contextual information. See
> "Emphasis" desc)))))
>
>
> +;;;; Node Property
> +
> +(defun org-odt-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element from Org to ODT.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (org-odt--encode-plain-text
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) "")))))
> +
> ;;;; Paragraph
>
> (defun org-odt--format-paragraph (paragraph contents default center quote)
> @@ -3005,11 +3018,11 @@ channel."
>
> (defun org-odt-property-drawer (property-drawer contents info)
> "Transcode a PROPERTY-DRAWER element from Org to ODT.
> -CONTENTS is nil. INFO is a plist holding contextual
> -information."
> - ;; The property drawer isn't exported but we want separating blank
> - ;; lines nonetheless.
> - "")
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (and (org-string-nw-p contents)
> + (format "<text:p text:style-name=\"OrgFixedWidthBlock\">%s</text:p>"
> + contents)))
>
>
> ;;;; Quote Block
> diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
> index d289e60..c834087 100644
> --- a/lisp/ox-texinfo.el
> +++ b/lisp/ox-texinfo.el
> @@ -89,6 +89,7 @@
> (keyword . org-texinfo-keyword)
> (line-break . org-texinfo-line-break)
> (link . org-texinfo-link)
> + (node-property . org-texinfo-node-property)
> (paragraph . org-texinfo-paragraph)
> (plain-list . org-texinfo-plain-list)
> (plain-text . org-texinfo-plain-text)
> @@ -1294,6 +1295,17 @@ are generated directly."
> ;;(org-texinfo--build-detailed-menu parse top info)
> (org-texinfo--build-menu parse 1 info 'detailed)))))
>
> +;;;; Node Property
> +
> +(defun org-texinfo-node-property (node-property contents info)
> + "Transcode a NODE-PROPERTY element from Org to Texinfo.
> +CONTENTS is nil. INFO is a plist holding contextual
> +information."
> + (format "%s:%s"
> + (org-element-property :key node-property)
> + (let ((value (org-element-property :value node-property)))
> + (if value (concat " " value) ""))))
> +
> ;;; Paragraph
>
> (defun org-texinfo-paragraph (paragraph contents info)
> @@ -1398,11 +1410,10 @@ information."
>
> (defun org-texinfo-property-drawer (property-drawer contents info)
> "Transcode a PROPERTY-DRAWER element from Org to Texinfo.
> -CONTENTS is nil. INFO is a plist holding contextual
> -information."
> - ;; The property drawer isn't exported but we want separating blank
> - ;; lines nonetheless.
> - "")
> +CONTENTS holds the contents of the drawer. INFO is a plist
> +holding contextual information."
> + (and (org-string-nw-p contents)
> + (format "@verbatim\n%s@end verbatim" contents)))
>
> ;;; Quote Block
>
> diff --git a/lisp/ox.el b/lisp/ox.el
> index 6c59368..7e1d932 100644
> --- a/lisp/ox.el
> +++ b/lisp/ox.el
> @@ -128,6 +128,7 @@
> (:with-latex nil "tex" org-export-with-latex)
> (:with-planning nil "p" org-export-with-planning)
> (:with-priority nil "pri" org-export-with-priority)
> + (:with-properties nil "prop" org-export-with-properties)
> (:with-smart-quotes nil "'" org-export-with-smart-quotes)
> (:with-special-strings nil "-" org-export-with-special-strings)
> (:with-statistics-cookies nil "stat" org-export-with-statistics-cookies)
> @@ -396,10 +397,11 @@ This option can also be set on with the CREATOR keyword."
> "Non-nil means export contents of standard drawers.
>
> When t, all drawers are exported. This may also be a list of
> -drawer names to export. If that list starts with `not', only
> -drawers with such names will be ignored.
> +drawer names to export, as strings. If that list starts with
> +`not', only drawers with such names will be ignored.
>
> -This variable doesn't apply to properties drawers.
> +This variable doesn't apply to properties drawers. See
> +`org-export-with-properties' instead.
>
> This option can also be set with the OPTIONS keyword,
> e.g. \"d:nil\"."
> @@ -557,6 +559,19 @@ e.g. \"pri:t\"."
> :group 'org-export-general
> :type 'boolean)
>
> +(defcustom org-export-with-properties nil
> + "Non-nil means export contents of properties drawers.
> +
> +When t, all properties are exported. This may also be a list of
> +properties to export, as strings.
> +
> +This option can also be set with the OPTIONS keyword,
> +e.g. \"prop:t\"."
> + :group 'org-export-general
> + :version "24.4"
> + :package-version '(Org . "8.2")
> + :type 'boolean)
> +
> (defcustom org-export-with-section-numbers t
> "Non-nil means add section numbers to headlines when exporting.
>
> @@ -2072,7 +2087,14 @@ a tree with a select tag."
> (not (eq todo-type with-tasks)))
> (and (consp with-tasks) (not (member todo with-tasks))))))))
> ((latex-environment latex-fragment) (not (plist-get options :with-latex)))
> + (node-property
> + (let ((properties-set (plist-get options :with-properties)))
> + (cond ((null properties-set) t)
> + ((consp properties-set)
> + (not (member-ignore-case (org-element-property :key blob)
> + properties-set))))))
> (planning (not (plist-get options :with-planning)))
> + (property-drawer (not (plist-get options :with-properties)))
> (statistics-cookie (not (plist-get options :with-statistics-cookies)))
> (table-cell
> (and (org-export-table-has-special-column-p
> diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
> index 54248cb..47c68d7 100644
> --- a/testing/lisp/test-ox.el
> +++ b/testing/lisp/test-ox.el
> @@ -479,6 +479,25 @@ Paragraph"
> (org-test-with-temp-text "CLOSED: [2012-04-29 sun. 10:45]"
> (org-export-as (org-test-default-backend)
> nil nil nil '(:with-planning nil))))))
> + ;; Property Drawers.
> + (should
> + (equal "* H1\n"
> + (org-test-with-temp-text
> + "* H1\n :PROPERTIES:\n :PROP: value\n :END:"
> + (org-export-as (org-test-default-backend)
> + nil nil nil '(:with-properties nil)))))
> + (should
> + (equal "* H1\n:PROPERTIES:\n:PROP: value\n:END:\n"
> + (org-test-with-temp-text
> + "* H1\n :PROPERTIES:\n :PROP: value\n :END:"
> + (org-export-as (org-test-default-backend)
> + nil nil nil '(:with-properties t)))))
> + (should
> + (equal "* H1\n:PROPERTIES:\n:B: 2\n:END:\n"
> + (org-test-with-temp-text
> + "* H1\n :PROPERTIES:\n :A: 1\n :B: 2\n:END:"
> + (org-export-as (org-test-default-backend)
> + nil nil nil '(:with-properties ("B"))))))
> ;; Statistics cookies.
> (should
> (equal ""
> --
> 1.8.4
>
[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2013-09-26 11:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-17 9:53 [Feature Request] Make property-drawers exportable Thorsten Jolitz
2013-06-17 14:33 ` Nicolas Goaziou
2013-06-17 15:48 ` Thorsten Jolitz
2013-06-17 18:54 ` Marcin Borkowski
2013-06-17 19:04 ` Nicolas Goaziou
2013-06-17 20:03 ` Thorsten Jolitz
2013-09-25 9:31 ` Carsten Dominik
2013-09-25 9:34 ` Carsten Dominik
2013-09-25 10:33 ` SUMMARY: " Carsten Dominik
2013-09-25 10:53 ` Thorsten Jolitz
2013-09-25 10:56 ` Carsten Dominik
2013-09-26 8:44 ` Marcin Borkowski
2013-09-25 11:51 ` Nicolas Goaziou
2013-09-25 12:08 ` Carsten Dominik
2013-09-25 12:13 ` Nicolas Goaziou
2013-09-25 12:26 ` Carsten Dominik
2013-09-25 20:57 ` Nicolas Goaziou
2013-09-26 11:28 ` Carsten Dominik [this message]
2013-09-26 11:48 ` Nicolas Goaziou
2013-09-26 11:51 ` Carsten Dominik
2013-09-26 14:33 ` Nicolas Goaziou
2013-09-26 16:06 ` Carsten Dominik
2013-09-25 12:52 ` Christian Moe
2013-09-25 12:12 ` Thorsten Jolitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58B8BF7F-E4B4-405F-8EC1-E73821BE7B18@gmail.com \
--to=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
--cc=tjolitz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.