I don’t think there’s an actual converter that can be used with asciidoctor that can do this.
It’s possible that asciidoctor-kramdown has something similar, as it emits asciidoc.
One difficulty with this is that it’s easy to create block trees that can render fine to html but that cannot be created from an asciidoc document.
For instance, it’s possible to have the blocks in a section be paragraph, section, paragraph, but when parsing asciidoc all the subsections have to be at the end of the blocks, with no paragraph blocks following.
On Aug 13, 2020, at 7:12 AM, guidog [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I want to create a new adoc file dynamically using this blocks
Thank you for the anwser, I will look into asciidoctor-kramdown to see how this tool creates the asciidoc files.
I need to walk over the block tree and translate the content (text only) and write the same file but translated. I want to take advantage of the parser and work with blocks or abstract blocks but it seems that it is not enough. (I don't care at the moment with include: directives)
I am checking both approach at this moment, create a backend to AsciiDoc or use some XML as intermediate languages.
It is possible that a backend (using converter) or a pretty printer (using doc.blocks) will not be same as the original code because there are instructions like #ifdef or any code executed by the preprossor or the parser (syntax sugar/alias). It is not a problem in my case, but I expect this kind of issues.
I'll let you know when I have something functional, even if it doesn't cover all functionality.
Yes, it's true that a converter cannot reproduce exactly the same document as the input. For one, the preprocessor reader runs before the parser and omits certain lines. But the parser also doesn't keep track of where it took metadata, so it's not possible for instance to recreate the attributes on a node (block or inline) in the exact same way. However, you could emit something more tidy ;)
> I'll let you know when I have something functional, even if it doesn't cover all functionality.