Closed andi-huber closed 4 years ago
I guess my question is whether there is already some Writer available that would do this for me. (don't want to reinvent the wheel if possible)
I am not aware of such a converter.
Ok, need to write some code then. Anyway thanks for the quick response!
The document object itself does not have a toAsciiDoc() feature, though it's certainly a reasonable suggestion.
Currently, all conversion is handled by the converter API. So one approach is to make an AsciiDoc converter. The convenience of the converter is that it walks the tree for you, so you only need to handle each node as it comes.
You may also be interested in the AsciiDoc writer I implemented for kramdoc. See https://github.com/asciidoctor/kramdown-asciidoc/blob/master/lib/kramdown-asciidoc/writer.rb. Poke around for how it is used.
Thanks for the directions!
I've started a Java project under the Apache Isis Tooling umbrella here: https://github.com/apache/isis/tree/master/tooling/asciidoc-model
Nowhere near complete, but we are yet able to model and write basic ascii-doc tables and will just extend as required.
Also if anybody is interested to contribute, we are happy to accept PRs. (Maven snapshots are published on a daily basis.)
If you haven't already, I strongly encourage you to join the specification effort for AsciiDoc under the AsciiDoc Working Group. See https://projects.eclipse.org/proposals/asciidoc-language and https://accounts.eclipse.org/mailing-list/asciidoc-wg. We'd certainly value your participation and input.
Due note that the AsciiDoc name is now trademarked by Eclipse Foundation. As such, I believe I'm accurate in saying that the project would need to be named model-for-asciidoc (or model4asciidoc) rather than asciidoc-model. (According to the guidelines, a project called something like "Foo for AsciiDoc" would be fine, but "Asciidoc Foo" would not. The former form suggests a separation, but the latter suggests a tight coupling). The project must also mention that AsciiDoc is a registered trademark of the Eclipse Foundation. We'll be putting out guidelines in the near future to help projects with naming. For now, see https://www.eclipse.org/lists/incubation/msg00723.html. The idea is to avoid confusion about what the AsciiDoc name means for the benefit of us all.
Thanks for the directions once more! I'll see that I update things to respect your policies.
Thanks Andi!
Project now moved to (in accordance with the suggested change of naming) ... https://github.com/apache/isis/tree/master/tooling/model4adoc
I also placed notices at multiple places (source code, artifact description, README) pointing to the info provided above. And also informing developers, that we are happy to help transferring source code, should there be any project, under the umbrella of the AsciiDoc Working Group, that is willing to take over.
That's awesome. I look forward to working with you! Great things ahead, especially in the development of APIs.
The document object itself does not have a toAsciiDoc() feature, though it's certainly a reasonable suggestion.
I was surprised to find out in this issue, after having written code using AsciidoctorJ to parse an existing document and change it slightly, that it is currently impossible to get the thus modified AsciiDoc form back. I was expecting to be able to generate it back as a string.
(Just wanted to mention that such a feature would be useful to at least one person.)
I'm also interested to find a way to load an existing adoc, modify it and save it back as an adoc file.
I didn't find anything useful at the moment, if anybody as any tips, examples, libraries that can do the trick ?
Thanks
Meanwhile for reference: The ASF project Isis was renamed to Apache Causeway. We also relocated the former AsciiDoc factory packages to
<dependency>
<groupId>org.apache.causeway.valuetypes</groupId>
<artifactId>causeway-valuetypes-asciidoc-builder</artifactId>
</dependency>
which is now part of our official releases. If all goes well, we'll have final releases 2.0.0
and 3.0.0
in spring (2024).
With these tools you can create AsciiDoc documents programmatically (from scratch). However, only a subset of features is supported.
See also https://github.com/apache/causeway/tree/master/valuetypes/asciidoc/builder
Hi @andi-huber ,
It doesn't seems that it answers to the first part of the requirement which is to load an existing adoc and modify it.
I have found this https://github.com/Swagger2Markup/markup-document-builder which seems to do quite the same thing as this one : https://github.com/apache/causeway/tree/master/valuetypes/asciidoc/builder
Any other ideas ?
Given following JUnit Test ...
How would I implement the helper method
toString(...)
at the bottom?Context: I do want to generate adoc syntax programmatically using Java. Thought the
asciidoctorj
abstract syntax tree would be an excellent model to get me started.