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

Operation macro corrupts snippets with UTF-8 characters #696

Closed
grolljak opened this issue Sep 11, 2020 · 3 comments
Closed

Operation macro corrupts snippets with UTF-8 characters #696

grolljak opened this issue Sep 11, 2020 · 3 comments

Comments

@grolljak
Copy link

Hi, I have a case where I need to include a special character ä inside documentation.

Plugins/Dependencies I am using:

id("org.springframework.boot") version "2.3.3.RELEASE"
id("org.asciidoctor.jvm.convert") version "3.2.0"
implementation("org.springframework.restdocs:spring-restdocs-mockmvc")
implementation("org.springframework.restdocs:spring-restdocs-asciidoctor")
asciidoctorExtensions("org.springframework.restdocs:spring-restdocs-asciidoctor")

Problematic part of generated snippet response-fields.adoc
|The zip type, one of [grossempfänger, normal, postfach, alte plz].

Then I am including this snippet in HTML documentation via:
include::{path}/response-fields.adoc[]
and also via:
operation::{name_of_the_snippet}[snippets='response-fields']

In the first case I get correct result generated in HTML:
The zip type, one of [grossempfänger, normal, postfach, alte plz].

In the second case, if I use operations macro:
The zip type, one of [grossempfänger, normal, postfach, alte plz].

I am suspecting an issue with parsing snippets in this file, but I am not that familiar with Ruby language: https://github.com/spring-projects/spring-restdocs/blob/master/spring-restdocs-asciidoctor-support/src/main/resources/extensions/operation_block_macro.rb

@wilkinsona
Copy link
Member

Thanks for the report. The problem only occurring with the operation macro definitely suggests that the Ruby code may be the problem. However, my understand is that with Ruby 2.x, the default string encoding is UTF-8. There are a few additional moving parts here, though, as the Ruby code is running on the JVM via JRuby.

What OS are you using and what is the default encoding set to?

@grolljak
Copy link
Author

Hi, I am running Windows 10. Can't find default encoding, but since I never changed it, I am assuming its Windows 10 default.

We have generated same documentation on MacOS and the characters are printed correctly. So this is local problem on my computer. I will investigate whether I am able to set correct encoding on OS/program level and will try to update this thread with solution. Thanks for fast response.

wilkinsona added a commit to wilkinsona/spring-restdocs that referenced this issue Sep 14, 2020
@wilkinsona wilkinsona changed the title Operation macro not supporting special characters Operation macro corrupts snippets with UTF-8 characters Sep 14, 2020
@wilkinsona
Copy link
Member

I've reproduced the problem on Windows by making some additions to REST Docs' test suite. Interestingly, the problem only appears to occur with more recent versions of AsciidoctorJ with 1.x being unaffected.

@wilkinsona wilkinsona added this to the 2.0.5.RELEASE milestone Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants