[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Weird behavior of org-element-object-lex
From: |
Damien Cassou |
Subject: |
Re: Weird behavior of org-element-object-lex |
Date: |
Thu, 20 Oct 2022 16:15:23 +0200 |
Damien Cassou <damien@cassou.me> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>> Damien Cassou <damien@cassou.me> writes:
>>> (defun ox-linuxmag--item (item contents info)
>>> ...
>>> The reason `ox-linuxmag--item` has to parse ITEM again is because
>>> CONTENTS contains "<text:p text:style-name="Normal">item 1 ;</text:p>"
>>> which misses the initial dash "-" character: i.e., I would like "- item
>>> 1 ;" in the paragraph instead.
After a quick chat with yantar92 on IRC, I understood that the easiest
solution is to fix the paragraph transcoder to inject the "- " when its
parent is an item. The item transcoder can just return CONTENTS.
Here is the corresponding code:
(defun ox-linuxmag--paragraph (paragraph contents info)
"Transcode a PARAGRAPH element from Org to ODT.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
(let* ((parent (org-export-get-parent paragraph))
(parent-type (org-element-type parent))
(prefix (when (eq parent-type 'item) "- ")))
(org-odt--format-paragraph
paragraph
(concat prefix contents)
info
(or (org-element-property :style paragraph) "Normal")
""
"")))))
Thank you so much for your help.
--
Damien Cassou
"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill