Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishToConfluence: Error rendering macro 'code' #402

Closed
tkleiber opened this issue Feb 5, 2020 · 18 comments · Fixed by #1242
Closed

publishToConfluence: Error rendering macro 'code' #402

tkleiber opened this issue Feb 5, 2020 · 18 comments · Fixed by #1242

Comments

@tkleiber
Copy link

tkleiber commented Feb 5, 2020

Describe the bug

Publish works, but contained code blocks:

[source, batch]
----
bin\doctoolchain c:\docToolchainTest publishToConfluence
----

are not generated. Instead on the Confluence page following is shown:

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
bin\doctoolchain docToolchainTest publishToConfluence

To Reproduce

Steps to reproduce the behavior:
1. checkout latest version doctoolchain commit 2023551398bb6e09e8db12d8e89c0e39e0d8e28b
2. create an new empty directory docToolchainTest
3. set JAVA_HOME=<JDK 1.8.0_181>
4. cd <docToolchain>
5. gradlew -b init.gradle initArc42EN -PnewDocDir=<docToolchainTest>
6. configure <docToolchainTest>\Config.groovy for Confluence
7. add the code shown before to arc42-template.adoc
8. bin\doctoolchain <docToolchainTest> publishToConfluence

Expected behavior
Code should be shown formatted in Confluence like in HTML or PDF

Screenshots
If applicable, add screenshots to help explain your problem.

Configuration

  • OS: Windows 10 Professional (Build), SLES 12 (Confluence)
  • Browser Chrome
  • Relevant SDK Versions JDK 1.8.0_181
  • Confluence Server 7.1.0

Additional context
Add any other context about the problem here.

@rdmueller
Copy link
Member

can you please retry and use [source, bash] or [source, html] instead of [source, batch]?
I have the feeling that confluence only allows a certain set of syntax highlighting types. "bash" and "html" should be in the list. I just found the following language in the dropdown of my own confluence instance:

ActionScript, AppleScript, Bash, C#, C++, CSS, ColdFusion, Delphi, Diff, Erlang, Groovy, HTML and XML, Java, Java FX, JavaScript, PHP, Perl, Plain Text, PowerShell, Python, Ruby, SQL, Sass, Scala, Visual Basic

I guess powershell might be closest to your use case.

@tkleiber
Copy link
Author

tkleiber commented Feb 6, 2020

bash and powershell works fine! Will look what match in the future. Maybe you should add this restriction to the documentation?

Find here that it is possible to add further languages :
https://confluence.atlassian.com/doc/code-block-macro-139390.html

@tkleiber tkleiber closed this as completed Feb 6, 2020
@raul1991
Copy link

Thanks a lot @tkleiber This makes that error disappear. But now the json looks like this

image

Is there a way to make it look like a formatted json ?

@tkleiber
Copy link
Author

tkleiber commented Apr 24, 2023

The error now happens with bash and powershell too in doctoolchain 2.2.1!

@tkleiber tkleiber reopened this Apr 24, 2023
@rdmueller
Copy link
Member

so, do I understand this correct that the problem is that confluence does not understand some of the syntaxt highlighting languages which are supported by asciidoc?

The code-block-macro and the valid languages are described here: https://confluence.atlassian.com/doc/code-block-macro-139390.html

The code in doctoolchain which tries to match asciidoc sntax highlighting with with confluence code blocks can be found here: https://github.com/docToolchain/docToolchain/blob/ng/scripts/asciidoc2confluence.groovy#L466

As I can see, there are already some rules defined.

Which rules do we miss?

@tkleiber
Copy link
Author

tkleiber commented Apr 25, 2023

After upgrading to version 2.2.1 already existing rules for bash and powershell does not work anymore.
This works until version 2.1.0.
Maybe relevant: Configuration createSubpages = true (2.1.0) / subpagesForSections = 2 (2.2.1).

@rdmueller
Copy link
Member

Six month ago, we changes the logic: https://github.com/docToolchain/docToolchain/blame/6e376b522d34cdb29814d33a4babe76382ec4106/scripts/asciidoc2confluence.groovy#L461

Can you see if a version from more than six month ago works for you?

Can you post the header of your asciidoc code block and the converted macro from confluence here? You can view the marco in conflzence by taking a look at the "storage format view" (I think this is what it is named in the right hand menu of a page)

@tkleiber
Copy link
Author

tkleiber commented Apr 25, 2023

Already told - 2.1.0 is working.
Have not tried 2.2.0 because of Issue #1054 in 2.2.1: fix for publishToConfluence was broken in v2.2.0
I don't see an option "storage format view" on my confluence page here. This is confluence 7.18.1 Server here.

View Source code of the browser (Edge) shows:

     </p><div class="content"> 
      Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'<pre class="conf-macro output-block" data-hasbody="true" data-macro-name="code">
         /test
        </pre> 
     </div> <p /> </li> 

"View Source" in the confluence page shows (Description of the image as I cannot upload one here):

Code Block | language = bash
/test

@rdmueller
Copy link
Member

thanx. I now had some more time to check this problem.

I use the following AsciiDoc source

.some code
[source, bash]
----
curl dtcw
chmod +x dtcw
----

And publish it to confluence (cloud instance) and it is correctly rendered as

image

Interestingly, my confluence says the code is rendered as "Shell" where your error massage says "bash"

dtcw - docToolchain wrapper V0.38
docToolchain V2.2.1
docker available
home folder exists

use local homefolder install /home/rdmueller/.doctoolchain/
Java Version 11

what is different to your setup?

@tkleiber
Copy link
Author

tkleiber commented Apr 26, 2023

The problem exist for header deeper than second level in combination with the configuration parameter subpagesForSections = 2 and docToolchain 2.2.1.

== second level header

[source,bash]
----
/install
----

=== third level header

[source,bash]
----
/install
----

The code block from second level header is rendered fine, the code block from the third level header (generated in the sub page) gives the error.

The same code renders both code blocks fine with configuration parameters createSubpages = true and allInOnePage = false and docToolchain 2.1.0.

Off topic: Why I can not upload screenshots here?

@hardyac
Copy link

hardyac commented Aug 18, 2023

i can confirm that this is a problem in all "depper" sections than 2. Is there a known workaround instead of going back (we have a very large document where we need 3-4)? For us it will be a show stopper. We already spend one day to find the issue, but without success. Confluence 7.19.0 .

@rdmueller
Copy link
Member

So, the first source renders as

<p><ac:structured-macro ac:name="toc"/></p><p>
<div class="content">
<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:plain-text-body><![CDATA[/install]]></ac:plain-text-body></ac:structured-macro>
</div>
</p><p><ac:structured-macro ac:name="children"><ac:parameter ac:name="sort">creation</ac:parameter></ac:structured-macro></p><p style="display:none">

or nicely formatted

<p><ac:structured-macro ac:name="toc"/></p>
<p>
  <div class="content">
  <ac:structured-macro ac:name="code">
    <ac:parameter ac:name="language">bash</ac:parameter>
    <ac:plain-text-body>
      <![CDATA[/install]]>
    </ac:plain-text-body>
  </ac:structured-macro>
</div>
</p>

The second one as

<p><ac:structured-macro ac:name="toc"/></p>
<p> 
 <div class="content"> 
  <ac:structured-macro ac:name="code">
   <ac:parameter ac:name="language">
    bash
   </ac:parameter>
   <ac:plain-text-body>
    <![CDATA[
     /install
    ]]>
   </ac:plain-text-body>
  </ac:structured-macro> 
 </div>

So, the main difference is that the second one is formatted and that there are line breaks around the "language" argument.

@rdmueller
Copy link
Member

So, it seems that the bug is in this line: https://github.com/docToolchain/docToolchain/blob/ng/scripts/asciidoc2confluence.groovy#L528

Seems to be a bug or unknown feature in the jsoup library. I will prepare a workaround.

rdmueller added a commit that referenced this issue Aug 18, 2023
@rdmueller
Copy link
Member

created a PR with the workaround. Do you know how you can instantly give this PR a try?

@rdmueller rdmueller linked a pull request Aug 18, 2023 that will close this issue
1 task
rdmueller added a commit that referenced this issue Aug 19, 2023
@rdmueller
Copy link
Member

Should be now available if you use version "latest"

@tkleiber
Copy link
Author

tkleiber commented Sep 7, 2023

Latest version on Github is from march and is version 2.2.1, where the error happens! So what do you mean with latest - do mean 3.0.0-rc1?

@rdmueller
Copy link
Member

dtcw lets you use "latest" as version which will clone the repository. This works with a local install.
But I also plan to release 3.0 this weekend

@tkleiber
Copy link
Author

tkleiber commented Sep 7, 2023

Last time I tried to dowload dtcw behind our corporate network I was not succesful.
Therefore I downloaded the release file and work with doctoolchain in bin directory directly.
Anyway I will wait till monday and retry it on both ways with 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants