docToolchain
docToolchain copied to clipboard
Confluence page does not render code callouts properly
One of my favorite features of asciidoctor is to be able to add callouts to code blocks, like this:
[source,yaml]
.Add cli to your docker-compose.yml
----
cli:
image: cli:v2.0.5
entrypoint: "tail" <1>
command: ["-f","/dev/null"] <1>
----
<1> This will override the default entrypoint `cli.sh` and just hang with a `tail -f /dev/null` to prevent docker from exiting. See link:../infrastructure/cli-docker.html[Article on cli] for details.
However Confluence does not seem to support this in their own code blocks.
When asciidoc2confluence rewrites the generated HTML to translate them to Confluence code blocks, the resulting callouts in the code block show as inlined HTML in the code, something like this:
cli:
image: cli:v2.0.5
entrypoint: "tail" <i class="conum" data-value="1"></i><b>(1)</b>
command: ["-f","/dev/null"] <i class="conum" data-value="1"></i><b>(1)</b>
Is it possible to just disable rewriting the code block, so that it is not recognized by confluence as a code block, and thus not to suffer from their limitations?
To Reproduce
- Add a code block with callouts to your asciidoctor file
- publishToConluence
- See resulting Confluence page
Expected behavior That the uploaded confluence page shows callouts like a normal asciidoctor rendered HTML page.
good idea, we can give it a try. But I guess that the code will then not get syntax highlighted...
you can give it a try by commenting out this line https://github.com/docToolchain/docToolchain/blob/master/scripts/asciidoc2confluence.groovy#L336
It should do the trick that the code block does not get rewritten...
If you do so, could you post screenshots of both rendereings?
Sure I'll post the screenshots
This is the rendering produced by Asciidoctor:
This is the rendering in Confluence with the current script:
This is the rendering in Confluence when shorting out the rewriteCodeblocks
method:
The no-conversion block looks ok, but we are of course sacrificing the code syntax highlighting.
I don't know enough html/css - fu to find a better solution than to just remove code conversion, b ut maybe there is a way to add some inline CSS styles to the <b>
element to make it look better, or inline a confluence macro? I' m really out of my depth here.
Is there an elegant way that you can think of, to allow your script to exclude generating a confluence code block, maybe by adding some special comment? I'm not sure that Asciidoctor comments are actually generating anything in the final html.
Maybe we could add an inocuous asciidoc code block option that will have a visible and parseable html result? Then the rewriteCodeblocks script could change its behaviour.
I guess I'm just asking if you've already had to do stuff like this in the project, and if yes, what's the recommended way.
I opened a PR. This works for our Confluence Version (6.13.3). I hope, this works on others, too.
It just does a line comment ("//") before the callout.
Maybe there is a more general solution that uses the correct comment chars for the programing language.
PR merged. Would be cool to get feedback.
Oh, this is cool. I'll give feedback as soon as I find some O2 for this.
I just patched my local installation with the changes from the PR. Looks good to me.
I just patched my local installation with the changes from the PR. Looks good to me.
@hbrands I just realized, that on our confluence this only renders correct, if we don't use subpages. Can you confirm or disprove this?
@bohni I tested with configuration createSubpages = false
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a small comment to keep it open. Thank you for your contributions.