Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
163 posts
|
I have 2 documents:
* document1.adoc * document2.adoc Imagine that document 2 looks like this : [source,asciidoc] ---- == Title A Lorem ipsum dolor sit amet, consectetur adipiscing elit. === Lorem Proin id nunc sit amet risus congue dictum. === Ipsum Aenean ut metus in leo auctor ornare. == Title B Duis fermentum, risus vitae fringilla fringilla, sapien dolor volutpat nibh, sit amet luctus dui velit lacinia nisi. ---- Is it possible to include an outline of the document2 in the document 1? For example I would like to get a nested list; looking like this: [source,text] ---- * Title A - Lorem - Ipsum * Title B ---- Each list item should be a link to the corresponding section in the other document. If the feature is not available, I can of course write it manually in the document1.adoc. It will be something like that: [source,asciidoc] ---- * <<document2.adoc#title-a, Title A>> ** <<document2.adoc#lorem, Lorem>> ** <<document2.adoc#ipsum, Ipsum>> * <<document2.adoc#title-b, Title B>> ---- But this presents the drawback that I need to reflect in document1 the structure of document2. Thank you in advance. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
Jeremie, It would be interesting to add an optional target to the `toc` block macro so it's possible to specify the source of the toc (by default it's the current document). ---- toc::document2.adoc[] ---- When the toc macro has a target, it would be used regardless of the value of the `toc` attribute on the document (since it's referring to a different source document). We'd probably have to construct the toc in a slightly different way to avoid clashes in the HTML and to link to the sections in the other document. wdyt? You could file a feature request in core. To get the feature sooner, you could play around with making a custom block macro extension that does essentially the same thing. You'd have to use a different name so as not to conflict with the built-in macro. ---- reference-toc::document2.adoc[] ---- Here's an example of a block macro extension from the extensions-lab to hopefully get you started. Cheers, -Dan On Wed, Apr 22, 2015 at 3:22 AM, Jeremie Bresson [via Asciidoctor :: Discussion] <[hidden email]> wrote: I have 2 documents: ... [show rest of quote] Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
In reply to this post by Jeremie Bresson
Btw, I think it would be fun to experiment with the extension in the extensions-lab until we work out getting it integrated into core. -Dan On Thu, Apr 30, 2015 at 6:15 PM, Dan Allen <[hidden email]> wrote:
... [show rest of quote] Dan Allen | http://google.com/profiles/dan.j.allen |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
163 posts
|
This thread is quite old, but I am still interested in creating a "reference-toc" macro.
I would like to develop it in Java (using AsciidoctorJ). My goal is to obtain a setup similar to the maven example java-extension-example. What I have managed is to read some asciidocContent and to get the parts... // asciidocContent contains the AsciiDoc source. public static List<ContentPart> getAllSectionParts(String asciidocContent) { Asciidoctor asciidoctor = create(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Asciidoctor.STRUCTURE_MAX_LEVEL, 6); StructuredDocument document = asciidoctor.readDocumentStructure(asciidocContent, parameters); List<ContentPart> parts = findSectionParts(document.getParts()); return parts; } //On each part, you can read: //part.getId(), part.getTitle(), part.getLevel()... private static List<ContentPart> findSectionParts(List<ContentPart> parts) { List<ContentPart> result = new ArrayList<ContentPart>(); if (parts != null) { for (ContentPart p : parts) { if ("section".equals(p.getContext())) { result.add(p); } result.addAll(findSectionParts(p.getParts())); } } return result; } Creating the corresponding AsciiDoc content (as text) will be easy... by combining "part.getLevel(), part.getId(), part.getTitle()": Forach parts as part repeat "*" part.getLevel() times concatenate <<{file name}#{part.getId()}, {part.getTitle()}>> concatenate new line Could you please give me some more inputs: * Which type of MacroProcessor should I take? * In the process(..) method, I should probably create "ulist" and "list_item" blocs. Have you some example? How could I test the block builder in a simple java main? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
2681 posts
|
Jérémie, If you are building an extension for AsciidoctorJ, I strongly recommend that you build it against AsciidoctorJ 1.6.0 (alpha). The AST API in AsciidoctorJ 1.5.x was merely a prototype. Thanks to Robert, the AST has been massively improved and is much more logical. It also has access to key information that was missing in the 1.5.x API. > Which type of MacroProcessor should I take? A block macro. > In the process(..) method, I should probably create "ulist" and "list_item" blocs. Yep. And this is where AsciidoctorJ 1.6.0 really comes into play because it has types for these. > Have you some example? Probably best to look at the test suite for AsciidoctorJ. Here's a good example (that creates a table, not a list, but very similar). Robert might be able to point you in a better direction. Cheers, -Dan On Thu, Jan 7, 2016 at 5:36 AM, Jeremie Bresson [via Asciidoctor :: Discussion] <[hidden email]> wrote: This thread is quite old, but I am still interested in creating a "reference-toc" macro. ... [show rest of quote] Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |