Ihor Radchenko <yanta...@posteo.net> writes:
> Damien Cassou <dam...@cassou.me> writes:
>> Is that a bug?
>
> Not really. table-cell and citation-reference do not have a regexp
> signature and are handled specially. For these two types of objects,
> org-element--object-lex is called only when the parent is a table-row or
> citation object. Not very elegant, but it is internal function, and it
> works :)

I understand. Thank you. This is a problem for me but the workaround is
easy. For information, the rest of this email describes my problem and
the workaround but I'm not expecting anything from you, the workaround
is good enough.

I'm writing an exporter that is basically the same as ODT with some
differences that are mandatory to get articles published in the magazine
GNU/Linux Magazine. This magazine wants lists to have no special markups:

      <text:p text:style-name="Normal">- item 1 ;</text:p>
      <text:p text:style-name="Normal">- item 2 ;</text:p>

So, I wrote a plain-list transcoder and an item transcoder:

  (defun ox-linuxmag--plain-list (plain-list contents _info)
    contents)

  (defun ox-linuxmag--item (item contents info)
    (let* ((plain-content (buffer-substring-no-properties
                           (org-element-property :contents-begin item)
                           (org-element-property :contents-end item)))
           (parse-tree (org-element-parse-secondary-string
                        plain-content
                        ;; org-element-parse-secondary-string acts
                        ;; weirdly if either 'table-cell or
                        ;; 'citation-reference are included:
                        (cl-remove-if
                         (lambda (type) (seq-contains-p '(table-cell 
citation-reference) type))
                         org-element-all-objects)))
           (item-content (org-export-data parse-tree info)))
      (ox-linuxmag--format-text:p (format "- %s" item-content))))

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.

As you can see, the code uses `org-element-parse-secondary-string` with
most of `org-element-all-objects` as RESTRICTION argument but neither
`table-cell` nor `citation-reference`.

Do you see a simpler way to achieve this?

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Reply via email to