emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to change the export semantics of the property-drawer?
@ 2017-09-15 17:54 Eduardo Bellani
  2017-09-15 19:49 ` Eduardo Bellani
  2017-09-15 20:02 ` Nicolas Goaziou
  0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Bellani @ 2017-09-15 17:54 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1745 bytes --]

Hello list.

I am trying to export the property-drawer as a description list on an
html derived backend, but I'm afraid I got stuck after some effort in
it.

Basically, I wanted this:

,----
| * Some
|   :PROPERTIES:
|   :CUSTOM_ID: 123
|   :END:
`----

To be exported *as if* it was this

,----
| * Some
|   - custom_id :: 123
`----

The problem I am facing is, how to resolve links in properties? The
example below illustrates the maximum point I've reached in my efforts

If someone can point me to a path, I'll be happy to follow it.

Thanks.

,----
| #+options: prop:t
|
| * some
|   :PROPERTIES:
|   :CUSTOM_ID: qwe123
|   :END:
|
| * another
|   :PROPERTIES:
|   :link:   [[#qwe123]]
|   :END:
|
|
|
| #+BEGIN_SRC emacs-lisp
|   (defun fee-html-property-drawer (property-drawer contents info)
|     "Transcode a property-drawer into a descriptive list."
|     (let* ((drawer-properties
|             (with-temp-buffer
|               (org-mode)
|               (insert (format "* H\n%s" (org-element-interpret-data property-drawer)))
|               (goto-char (point-min))
|               (org-element--get-node-properties)))
|            (dlist))
|       (--> drawer-properties
|            (ht<-plist it)
|            (ht-map (-lambda (key value)
|                      (format "- %s :: %s"
|                              (string-trim (symbol-name key) ":") value))
|                    it)
|            (string-join it "\n")
|            (org-export-string-as it
|                                  'html
|                                  t
|                                  info))))
|
|   (org-export-define-derived-backend 'fee-html 'html
|     :translate-alist '((property-drawer . fee-html-property-drawer)))
| #+END_SRC
|
`----

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 180 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to change the export semantics of the property-drawer?
  2017-09-15 17:54 How to change the export semantics of the property-drawer? Eduardo Bellani
@ 2017-09-15 19:49 ` Eduardo Bellani
  2017-09-15 20:02 ` Nicolas Goaziou
  1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Bellani @ 2017-09-15 19:49 UTC (permalink / raw)
  To: Eduardo Bellani; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

Sorry, I forgot about the subject tag.

Eduardo Bellani writes:

> Hello list.
>
> I am trying to export the property-drawer as a description list on an
> html derived backend, but I'm afraid I got stuck after some effort in
> it.
>
> Basically, I wanted this:
>
> ,----
> | * Some
> |   :PROPERTIES:
> |   :CUSTOM_ID: 123
> |   :END:
> `----
>
> To be exported *as if* it was this
>
> ,----
> | * Some
> |   - custom_id :: 123
> `----
>
> The problem I am facing is, how to resolve links in properties? The
> example below illustrates the maximum point I've reached in my efforts
>
> If someone can point me to a path, I'll be happy to follow it.
>
> Thanks.
>
> ,----
> | #+options: prop:t
> |
> | * some
> |   :PROPERTIES:
> |   :CUSTOM_ID: qwe123
> |   :END:
> |
> | * another
> |   :PROPERTIES:
> |   :link:   [[#qwe123]]
> |   :END:
> |
> |
> |
> | #+BEGIN_SRC emacs-lisp
> |   (defun fee-html-property-drawer (property-drawer contents info)
> |     "Transcode a property-drawer into a descriptive list."
> |     (let* ((drawer-properties
> |             (with-temp-buffer
> |               (org-mode)
> |               (insert (format "* H\n%s" (org-element-interpret-data property-drawer)))
> |               (goto-char (point-min))
> |               (org-element--get-node-properties)))
> |            (dlist))
> |       (--> drawer-properties
> |            (ht<-plist it)
> |            (ht-map (-lambda (key value)
> |                      (format "- %s :: %s"
> |                              (string-trim (symbol-name key) ":") value))
> |                    it)
> |            (string-join it "\n")
> |            (org-export-string-as it
> |                                  'html
> |                                  t
> |                                  info))))
> |
> |   (org-export-define-derived-backend 'fee-html 'html
> |     :translate-alist '((property-drawer . fee-html-property-drawer)))
> | #+END_SRC
> |
> `----

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 180 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to change the export semantics of the property-drawer?
  2017-09-15 17:54 How to change the export semantics of the property-drawer? Eduardo Bellani
  2017-09-15 19:49 ` Eduardo Bellani
@ 2017-09-15 20:02 ` Nicolas Goaziou
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Goaziou @ 2017-09-15 20:02 UTC (permalink / raw)
  To: Eduardo Bellani; +Cc: emacs-org list

Hello,

Eduardo Bellani <ebellani@gmail.com> writes:

> I am trying to export the property-drawer as a description list on an
> html derived backend, but I'm afraid I got stuck after some effort in
> it.
>
> Basically, I wanted this:
>
> ,----
> | * Some
> |   :PROPERTIES:
> |   :CUSTOM_ID: 123
> |   :END:
> `----
>
> To be exported *as if* it was this
>
> ,----
> | * Some
> |   - custom_id :: 123
> `----
>
> The problem I am facing is, how to resolve links in properties? The
> example below illustrates the maximum point I've reached in my efforts
>
> If someone can point me to a path, I'll be happy to follow it.

I would use a tree filter that transforms property drawers into
description lists right in the parse tree.

If you know a value is a link, you can use
`org-element-parse-secondary-string' on it.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-15 20:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-15 17:54 How to change the export semantics of the property-drawer? Eduardo Bellani
2017-09-15 19:49 ` Eduardo Bellani
2017-09-15 20:02 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).