Unexpected change of font inside <pre>

bloodnok
Posts: 53
Joined: Mon Jun 27, 2011 10:51 pm

Unexpected change of font inside <pre>

Post by bloodnok » Wed Apr 15, 2020 1:47 am

Trying to display a ssh public key. This is my source:

Code: Select all

<codeblock outputclass="nobreak"><ph conref="variables.dita#variables/llPrompt"/> <userinput>cat ~/.ssh/authorized_keys</userinput>
ssh&#8209;rsa&#160;AAAADAQABAAABAQDn2hZvQiXAAAAB3NzaC1yc2EDWNQ9AOF6JvcoMbDGUrh0C6WWTdDvQZA0vTwAbeIdjkAlcoRN1BU9BLQo19W8eXsl9PRB4bN2Mu1P0XIWCIjiAVxOSJsP8rhMVoQkGES2vA+uqyqqPincLDfF0u6DetIyW+1nC6uEwtS6Bc9s6FnALBVjcjil6yZveGzuLqAvj9C4zl3ZoA24DUkkH25lzK3NNKJDUSgrhnkm9ouirjsCmfGPLwnS7p9VzYVkFmwnnygJLGEZf3mXgwSYMH1BcuHdbhFVKkzZicrmR2vSkSimTp50riZ3xDX91qpQskV9I4aFS9DtcsumjvDYA87Xend3vf&#160;system@example.com
ssh&#8209;rsa&#160;AAAAB3NzaC1yc2EAAAADAQABAAABAQDNrBpwY54v4XDePpQlDOBNpQpyBuJnPY3ThAE3YPAtqlboKeiUNDDgHbYLVVdXV8CFpvShaJ1oFZj5CNjp4krD9Bx2aK3QpoRX3e3ZWSv2JxlbBs61J4fTiKnyDyeGcqx3Q2JjgRTww5AfE4c5GYZrpPTG5UkKfd6Jl8Pq1qyatHWXhCTpquOqPB1lTmS0f2gna8CMVyunV1CLVhmQVeNU2EgGQMh2wJpxO59ohNVD950HJM6lJiQVoAk7nAoJvvcHkCmrB7SSVN7xv2FIthYswVWnPU58BELwJazCu7qKcxKt0T6MdVhnZSiv64M56EBUJyXd7F3&#160;admin@example.com</codeblock>
Works as expected when converted to HTML. This is the HTML source:

Code: Select all

<pre class="pre codeblock nobreak"><code><span class="ph">lastline@lastline-<span class="ph">manager</span>:~$</span> <kbd class="ph userinput">cat ~/.ssh/authorized_keys</kbd>
ssh‑rsa&nbsp;AAAADAQABAAABAQDn2hZvQiXAAAAB3NzaC1yc2EDWNQ9AOF6JvcoMbDGUrh0C6WWTdDvQZA0vTwAbeIdjkAlcoRN1BU9BLQo19W8eXsl9PRB4bN2Mu1P0XIWCIjiAVxOSJsP8rhMVoQkGES2vA+uqyqqPincLDfF0u6DetIyW+1nC6uEwtS6Bc9s6FnALBVjcjil6yZveGzuLqAvj9C4zl3ZoA24DUkkH25lzK3NNKJDUSgrhnkm9ouirjsCmfGPLwnS7p9VzYVkFmwnnygJLGEZf3mXgwSYMH1BcuHdbhFVKkzZicrmR2vSkSimTp50riZ3xDX91qpQskV9I4aFS9DtcsumjvDYA87Xend3vf&nbsp;system@example.com
ssh‑rsa&nbsp;AAAAB3NzaC1yc2EAAAADAQABAAABAQDNrBpwY54v4XDePpQlDOBNpQpyBuJnPY3ThAE3YPAtqlboKeiUNDDgHbYLVVdXV8CFpvShaJ1oFZj5CNjp4krD9Bx2aK3QpoRX3e3ZWSv2JxlbBs61J4fTiKnyDyeGcqx3Q2JjgRTww5AfE4c5GYZrpPTG5UkKfd6Jl8Pq1qyatHWXhCTpquOqPB1lTmS0f2gna8CMVyunV1CLVhmQVeNU2EgGQMh2wJpxO59ohNVD950HJM6lJiQVoAk7nAoJvvcHkCmrB7SSVN7xv2FIthYswVWnPU58BELwJazCu7qKcxKt0T6MdVhnZSiv64M56EBUJyXd7F3&nbsp;admin@example.com</code></pre>


But when the HTML is processed through Chemistry it results in an unexpected and unwanted font change. See the png attachment. The text "ssh-rsa" looks like helvetica or arial and isn't aligned with the other text.
fontchange.png
fontchange.png (214.21 KiB) Viewed 638 times
Have I tickled yet another bug?

julien_lacour
Posts: 100
Joined: Wed Oct 16, 2019 3:47 pm

Re: Unexpected change of font inside <pre>

Post by julien_lacour » Wed Apr 15, 2020 10:20 am

Hello,

Can you reproduce the problem without using any customization (or just using the outputclass="nobreak" rule from your CSS customization)?
Which version of Oxygen are you currently using? I tried on the last version from our website and the default transformation without reproducing the issue.

If you still reproduce the problem, please provide us your CSS customization at support@oxygenxml.com.

Regards,
Julien

bloodnok
Posts: 53
Joined: Mon Jun 27, 2011 10:51 pm

Re: Unexpected change of font inside <pre>

Post by bloodnok » Thu Apr 16, 2020 6:58 am

We're running oxygen-pdf-chemistry-22.0.

Here's the CSS:

Code: Select all

/*RSA kludge*/
.nobreak{
  overflow-wrap: break-word;
}
Another issue is the hyphenation in the code block: How can I suppress that? It's supposed to represent the output from an ASCII terminal. I was expecting the lines to just break at the edge.

bloodnok
Posts: 53
Joined: Mon Jun 27, 2011 10:51 pm

Re: Unexpected change of font inside <pre>

Post by bloodnok » Sat Apr 18, 2020 6:22 am

BTW: if I disable the .nobreak CSS, I still get the unexpected font change but the text just runs off the side of the page.
evenmorebroken.png
evenmorebroken.png (51.22 KiB) Viewed 566 times

bloodnok
Posts: 53
Joined: Mon Jun 27, 2011 10:51 pm

Re: Unexpected change of font inside <pre>

Post by bloodnok » Sat Apr 18, 2020 9:11 pm

Regarding hyphenation, I modified my CSS:

Code: Select all

/*RSA kludge*/
.nobreak{
  hyphens: none;
  overflow-wrap: break-word;
}
The "hyphens" directive is ignored by Chemistry.

julien_lacour
Posts: 100
Joined: Wed Oct 16, 2019 3:47 pm

Re: Unexpected change of font inside <pre>

Post by julien_lacour » Fri Apr 24, 2020 10:23 am

Hello,

For the font issue, you should be able to resolve it by surrounding your words by a <ph>:

Code: Select all

ssh&#8209;rsa&#160;
<ph>ssh-rsa </ph>
For the hyphenation issue, starting with Oxygen 22.1 (release is in a few weeks), you will be able to set the overflow-wrap property

Code: Select all

.nobreak{
  overflow-wrap: break-word;
}
You content will look like this:
overflow-wrap.png
overflow-wrap.png (50.28 KiB) Viewed 461 times
Regards,
Julien

bloodnok
Posts: 53
Joined: Mon Jun 27, 2011 10:51 pm

Re: Unexpected change of font inside <pre>

Post by bloodnok » Sat Apr 25, 2020 3:07 am

I tried both <ph> and the <codeph> to no effect. Either results with the san serif font on "ssh-rsa". <codeph> was worse as it also breaks the HTML rendering.

However, if I replace the non-breaking hyphen and the non-breaking space with normal characters, the font change doesn't occur. Unfortunately that breaks the desired effect in the HTML rendering, so it's not a solution.

julien_lacour
Posts: 100
Joined: Wed Oct 16, 2019 3:47 pm

Re: Unexpected change of font inside <pre>

Post by julien_lacour » Tue Apr 28, 2020 11:41 am

Hello,

I tried to reproduce the issue on <oXygen/> XML Editor 22.0, build 2020030607 but on my side the "ssh-rsa" looks normal (as on my previous picture).
Is it possible for you to send us a small sample (at support@oxygenxml.com)?
We just need the ditamap file and the topics involved in the codeblock.

Can you also confirm the scenario? Are you running the transformation inside Oxygen or in a separate command line?

Regards,
Julien

julien_lacour
Posts: 100
Joined: Wed Oct 16, 2019 3:47 pm

Re: Unexpected change of font inside <pre>

Post by julien_lacour » Thu Apr 30, 2020 10:34 am

Hello,

The problem is caused by the non-breaking hyphen character: the font used for the codeblock cannot render it, so it is rendered using one of our fallback font (used for CJK languages).
The best solution is to replace it by a combination of word joiner and normal hyphen:

Code: Select all

ssh&#x2060;-&#x2060;rsa&nbsp;
Regards,
Julien

bloodnok
Posts: 53
Joined: Mon Jun 27, 2011 10:51 pm

Re: Unexpected change of font inside <pre>

Post by bloodnok » Mon May 04, 2020 8:07 pm

Great feedback from the Support team and a usable solution. Thanks Julien.

Post Reply