spring-io / spring-asciidoctor-extensions

Asciidoctor Extensions developed by the Spring team
46 stars 18 forks source link

Callout only applies to role="primary" with block-switch #86

Closed corneil closed 3 years ago

corneil commented 3 years ago

When using [source] with callouts and expecting block-switch to create tabs for each, the callout section is only visible along with the role="primary" section. Selecting the role="secondary" item hides the callouts below the source sections. If a callout section is added after role="primary" then the block-switch doesn't take effect and you end up with 2 or more source blocks followed by each set of callouts. The callout is part of the <div data-block-name="primaryTitle"> instead of being after all <div class="content"> sections within the <div class="switch">

wilkinsona commented 3 years ago

Thanks for the report. The behaviour that you have described doesn't match my own experience. For example, this section of the Spring REST Docs documentation uses callouts for both Maven and Gradle and it switches between them as expected.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

wilkinsona commented 3 years ago

This may be a duplicate of https://github.com/spring-io/spring-asciidoctor-extensions/issues/80 which should be fixed in 0.6.0.

corneil commented 3 years ago

I tested with 0.6.0 I have submitted PR #87 which changes where the block is appended.

corneil commented 3 years ago

This simple project show the problem and has the generated HTML of the 2 versions.

https://github.com/corneil/block-switch-test

wilkinsona commented 3 years ago

Thanks for the sample. The source that you're using is incorrect. You've only provided callouts for one of the two blocks so it's to be expected that they're only shown once. If you want both blocks to have callouts, those callouts needed to be written twice (even if they're identical). The correct source is the following:

= Test

Illustrate block-switch with callout.

[source,groovy,role="primary"]
.Groovy DSL
----
plugins {
    id 'java'
    id 'org.springframework.boot' version '2.2.7.RELEASE' // <1>
    id 'io.spring.dependency-management' version '1.0.11.RELEASE' // <2>
}
----
<1> Spring Boot plugin
<2> Spring Dependency Management plugin

[source,kotlin,role="secondary"]
.Kotlin DSL
----
plugins {
    id("java")
    id("org.springframework.boot") version "2.2.7.RELEASE" // <1>
    id("io.spring.dependency-management") version "1.0.11.RELEASE" // <2>
}
----
<1> Spring Boot plugin
<2> Spring Dependency Management plugin

Note that I've also removed the whitespace between the end of the block and the first callout in each case. This aligns with the examples in the Asciidoctor documentation.

corneil commented 3 years ago

I eventually spent some time tracking down the issue and found that with some file asciidoctorj version 2.3.0 doesn't add the style and script elements to the produced HTML. By setting the asciidoctorj version to 2.4.3 to elements are present and work as expected.