Extra space added for <codeblock> and <codeph>

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Thu May 16, 2019 5:47 am

Hi everyone,

I'm using "DITA Map PDF - based on HTML5 & CSS" in XML Author 21 to generate PDF documents, and I found sometimes an extra space is inserted for the <codeblock> and <codeph> tags.
  • For the following code, and extra space is inserted at the beginning of the code block:

    Code: Select all

    by removing the following two lines:
    <codeblock>&lt;extension module="org.jboss.as.jaxrs"/>
    &lt;subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/></codeblock>
  • For the <codeph> tag, if a punctuation mark such as a comma or period is added right after it, an extra space is inserted before the punctuation mark. Like in the following code:

    Code: Select all

    ...are also controlled in <codeph>customer.xml</codeph>. 
I'm not sure how to solve the problem. Can anyone give me a hand?

Thanks,
Michael

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Extra space added for <codeblock> and <codeph>

Post by Dan » Thu May 16, 2019 10:16 am

Hello Michael,

The transformation add a code inside the pre element. This is an inline element, that has some padding set from the built-in CSS. You should remove its padding:

Code: Select all

pre{
	padding:2px 4px;
}
pre > code{
	padding:0;
}
I fixed this in the default CSSs.

If you encounter more problems, please consider debugging the CSS as explained here:
https://www.oxygenxml.com/doc/versions/ ... e_css.html

Thank you for the feedback,
Dan

chrispitude
Posts: 66
Joined: Thu May 02, 2019 2:32 pm

Re: Extra space added for <codeblock> and <codeph>

Post by chrispitude » Mon May 20, 2019 4:29 pm

Hi Michael,

After Oxygen XML Support guided me to open the merged HTML in Chrome and inspect styles there, I have been using it quite heavily to debug PDF formatting issues. I imagine you'll find it quite useful too!

Don't forget to set the rendering mode to "print":

https://www.oxygenxml.com/doc/versions/ ... gging.html

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: Extra space added for <codeblock> and <codeph>

Post by Radu » Thu May 23, 2019 2:49 pm

Hi,

We released Oxygen 21.1 and it should have this fix included.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Re: Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Mon May 27, 2019 2:38 am

Thanks so much, guys. I will try to upgrade to Oxygen 21.1 then.

Cheers,
Michael

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Re: Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Mon May 27, 2019 3:01 am

Tried Oxygen 21.1 and found that the issue was not fixed. In addition, my document title goes up and overlaps with the company icon. I think the "margin-top" property does not work properly in the following code:

Code: Select all

/* Document title on cover page */
*[class~="front-page/front-page-title"] {
    display: block;
    text-align: center;
    margin-top: 34%;
    font-size: 2.6em;
    font-weight: bold;
    line-height: 105%;
}
Guess I'd better revert to Oxygen 21 and fix the issue manually. :-(

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Re: Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Mon May 27, 2019 6:18 am

Hi Dan,

I tried your code and the issue was basically fixed. However, for the <codeph> before a punctuation mark, such as a comma or a period, an extra space is still inserted before the punctuation mark. I think it is not a padding issue because for <codeph> between two words, everything is okay. And I checked the generated HTML and found nothing was inserted there.

Do you have any idea how to fix that issue?

Cheers,
Michael
Dan wrote:
Thu May 16, 2019 10:16 am
Hello Michael,

The transformation add a code inside the pre element. This is an inline element, that has some padding set from the built-in CSS. You should remove its padding:

Code: Select all

pre{
	padding:2px 4px;
}
pre > code{
	padding:0;
}
I fixed this in the default CSSs.

If you encounter more problems, please consider debugging the CSS as explained here:
https://www.oxygenxml.com/doc/versions/ ... e_css.html

Thank you for the feedback,
Dan

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Extra space added for <codeblock> and <codeph>

Post by Dan » Mon May 27, 2019 11:15 am

Hello Michael,

I tried to use the DITA sample:

Code: Select all

[Oxygen Install Dir]\samples\dita\it-book\taskbook.ditamap
and the standard HTML transformation using the 'ashes' template but I cannot reproduce the problem.

Please try to use a standard publishing template (the first tab in the transformation scenario), with no customization.
Open the FO file from the output folder and search for the codeph text. Check if there is a space in the text. You can take a look also into the .style.xml file.

If you do not detect the cause, please send us more details, like the full DITA fragment, and the FO fragment.

Many regards,
Dan

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Re: Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Tue May 28, 2019 2:46 am

Hi Dan,

It is not that obvious in the generated PDF. If you copy the text into a text editor, you will see an extra space before the punctuation mark. I tested again and found that there is no extra space in the .fo file. Guess the issue might be related to the process that transforms the .fo and .html files into a single PDF.

My environment is as follows:
  • Version: Oxygen Author 21
  • Transformation Scenario: DITA Map PDF - based on HTML5 & CSS
  • Template: Ashes [tiles]
My test DITA file is as follows:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="test">
    <title>test</title>
    <shortdesc></shortdesc>
    <conbody>
        <p>This is a test for <codeph>codeph</codeph>.</p>
    </conbody>
</concept>
My test DITAMAP file is as follows:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
    <title>test map</title>
    <topicref href="test.dita"/>
</map>
The relevant code in the generated .fo file is as follows:

Code: Select all

<fo:block-container margin-bottom="0.5em" margin-left="0" margin-right="0" margin-top="1em"><fo:block end-indent="0" start-indent="0">This is a test for <fo:inline font-family="monospace" font-size="smaller" role="Code" padding-bottom="2px" padding-left="4px" padding-right="4px" padding-top="2px">codeph</fo:inline>.</fo:block></fo:block-container>
If I copy the text from the generated PDF and paste into a text editor, the result is as follows:

Code: Select all

This is a test for codeph .
Note there is a space between the letter h and the period.

Let me know if you need more info.

Cheers,
Michael

Dan
Posts: 428
Joined: Mon Feb 03, 2003 10:56 am

Re: Extra space added for <codeblock> and <codeph>

Post by Dan » Tue May 28, 2019 9:44 am

Thank you for the details!

The problem is caused by the

Code: Select all

padding-right="4px"
. This looks like either our fix from the built-in CSS is not working, or you have such padding set in the customization CSS.

Please open the merged HTML file in a browser (Chrome for instance), and using the developer tools inspect the element containing the codeph text. You will see what rules are applying and from what CSS.

More information about debugging the CSSs is here: https://www.oxygenxml.com/doc/versions/ ... ng_the_css

Many regards,
Dan

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Re: Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Wed May 29, 2019 6:38 am

You are quite right, Dan. I added the following code into my customization css and the problem was solved:

Code: Select all

code{
	padding:0 0 !important;
}
Thanks again!

Cheers,
Michael

shanweizhong
Posts: 30
Joined: Mon Jul 10, 2017 2:18 am

Re: Extra space added for <codeblock> and <codeph>

Post by shanweizhong » Wed May 29, 2019 7:54 am

Radu wrote:
Thu May 23, 2019 2:49 pm
Hi,

We released Oxygen 21.1 and it should have this fix included.

Regards,
Radu
Hi Radu,

I tested and I think the fix is not included in 21.1.

Cheers,
Michael

Post Reply