Login  Register

nest inclusions with level offsets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

nest inclusions with level offsets

xcoulon
30 posts
Hello,

I'm trying to understand how nested file inclusions with level offsets are processed. Here's my use-case:

'test.adoc':
    = main title

    include:parent-include.adoc[leveloffset=+1]

'parent-include.adoc':
    = parent title

    include:child-include.adoc[leveloffset=+1]

'child-include.adoc':
    = child title

    include:grandchild-include.adoc[]

'grandchild-include.adoc':
    == grandchild title

(Note the 'leveloffset' attribute when including the 'child-include.adoc' file in the 'parent-include.adoc' one)

I would expect that these relative nested leveloffset would combine/accumulate and give the following output when processing the `test.adoc` top-level file:
   <h1>main title</h1>
   ...
   <h2>parent title</h2>
   ...
   <h3>child title</h3>
   ...
   <h4>grandchild title</h4>
   ...

But instead, asciidoctor 2.0.10 gives the following result:
   <h1>main title</h1>
   ...
   <h2>parent title</h2>
   ...
   <h2>child title</h2>
   ...
   <h3>grandchild title</h3>
   ...

as if the `leveloffset` attribute in the `include:child-include.adoc[leveloffset=+1]` macro in the `parent-include.adoc` file was ignored.

Is it the expected behaviour or is it a limitation or a (known) issue?


   
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: nest inclusions with level offsets

habamax
55 posts
I have tried to replicate it and I couldn't.



Note, I have used double :: instead of single :

Single : didn't work for me at all



And the html is

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: nest inclusions with level offsets

xcoulon
30 posts
ah yes sorry, that was a bad copy/paste on my side, I used the `include::` syntax (ie, with 2 colons)
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: nest inclusions with level offsets

xcoulon
30 posts
In reply to this post by habamax
Ohhh, I found my mistake! I did not include the right file from the beginning (facepalm)
Running again with the correct file inclusions, I get the expected result (with leveloffsets being accumulated):
asciidoctor -o - tmp/test.adoc | grep -e "<h\d"
<h1>main title</h1>
<h2 id="_parent_title">parent title</h2>
<h3 id="_child_title">child title</h3>
<h4 id="_grandchild_title">grandchild title</h4>

Thanks for your response and your time to reproduce and verify, @habamax!