How to convert AsciiDoc to Odt without anchors and metadata

147 Views Asked by At

I'm trying to convert AsciiDoc files to Odt using the following commands in sequence:

/usr/bin/asciidoctor \
    --destination-dir=/tmp \
    --backend=docbook5 \
    --attribute=leveloffset=+1 \
    some_file.adoc

/usr/bin/pandoc \
    --wrap=none \
    --atx-headers \
    --from=docbook \
    --to=markdown /tmp/some_file.xml \
    --output=/tmp/some_file.md

/usr/bin/pandoc \
    --from=markdown \
    --to=odt /tmp/some_file.md \
    --output=/tmp/some_file.odt

It works, but some metadata is being included like "{#_some_title}", ":imagesdir:", etc...

# Some Title {#_some_title}

Author Name \<<[email protected]>\> June, 22 2023 :doctype: book :imagesdir: images

 :hyphens: pt :author: Author Name :email: <[email protected]>

## Some header {#_some_header}

What am I doing wrong? How can I convert without the anchor sequences "{#_some_title}" and the metadata?

(just to confirm, the original AsciiDoc file is rendered perfectly. The problem only happens in the conversion)

Thanks

1

There are 1 best solutions below

0
eskwayrd On

The first problem is having the attribute definitions in the content. That happens when using an "author" line in your AsciiDoc file. Try removing the author line and instead use the author attribute.

The second problem is having the section ids appear as content. That's due to the ATX headers, which became the default in 2020, and the --atx-header option is no longer valid in recent versions of pandoc. I'd suggest that you upgrade your version of pandoc.

When you converted the DocBook XML to Markdown, your output format is markdown, Pandoc's version of Markdown. If you use markdown_strict, you don't get the ATX headers in the output.