newlines not working in <codeblock> tags

<oXygen/> general issues.
wmaclean
Posts: 38
Joined: Sat Jan 04, 2020 1:17 am

newlines not working in <codeblock> tags

Post by wmaclean » Fri Jan 08, 2021 10:14 pm

Hello,
We have an xml topic which uses newlines in a <codeblock> tag, but the output does not use the newlines, instead wrapping the text and losing the indentations.

Please see the example "Windows Sample Script" here:
https://docs.oracle.com/en/cloud/saas/e ... ipt_1.html

In oxygen, you can see the newlines and correct indent:
image.png
image.png (161.33 KiB) Viewed 498 times
Someone had said they thought there might be an Oxygen setting to enable newlines in <codeblock> tags. Is there such a thing? Or, what am I missing?

Thanks,
Will

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

Re: newlines not working in <codeblock> tags

Post by julien_lacour » Mon Jan 11, 2021 10:11 am

Hello Will,

It seems that your XML document is a DITA topic, could you confirm?
Could you also indicate in which output does the problem occur? (PDF, WebHelp, etc.)

Regards,
Julien

wmaclean
Posts: 38
Joined: Sat Jan 04, 2020 1:17 am

Re: newlines not working in <codeblock> tags

Post by wmaclean » Mon Jan 11, 2021 9:46 pm

Hi Julien,
Yes - our source is a DITA topic. And we are losing the newlines in <codeblock> in both PDF and HTML output.

Thanks for your help.
Will

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

Re: newlines not working in <codeblock> tags

Post by Radu » Tue Jan 12, 2021 1:48 pm

Hi Will,

Are you using for publishing Oxygen's bundled DITA Open Toolkit publishing engine or a custom publishing engine?
Did you maybe install an extra publishing plugin which may have induced this problem? Because on my side this problem does not occur when publishing with Oxygen's publishing engine to HTML5 or PDF.

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

wmaclean
Posts: 38
Joined: Sat Jan 04, 2020 1:17 am

Re: newlines not working in <codeblock> tags

Post by wmaclean » Tue Jan 12, 2021 7:42 pm

Hello Radu,
We are migrating from Arbortext to Oxygen, and have ported the DITA-OT 1.8.5 into Oxygen as a Framework.

Basically, our custom Oxygen plugin creates the DITA command as a string, and executes it through a Runtime class using a bat file to call ant. The ant call looks basically like:

ant -f build.xml -Dclean.temp=yes -Ddita.dir=C:\dir -Dbasedir=C:\dir
-Dtranstype=pdf-epm
-Dargs.input=C:\dita_files\publications.ditamap
-Doutput.dir=C:\output
-Dargs.filter=C:\publication.ditaval
-Ddita.map.filename.root=aName
-Dargs.doc.source.dir=C:\dita_files\publication.ditamap

This same setup worked in Arbortext, while preserving newlines and tabs in <codeline> tags.

Would you know of any settings in Oxygen I can try, or arguments I can pass to DITA that might help preserve the endlines and tabs in <codeblock> tags?

Is there somewhere in the Oxygen folder setup I can look to see how Oxygen's publishing engine makes the same sort of call to DITA?

Thanks for anything you can offer.
Will

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

Re: newlines not working in <codeblock> tags

Post by Radu » Wed Jan 13, 2021 8:55 am

Hi Will,

That ant call you are making from the Oxygen plugin creates a new process, totally separated from Oxygen.
Can you try to open a Windows command prompt and run inside it the same process? Does it yield the same results?
Is it possible that since migrating from Arbortext you also made changes to the publishing? Maybe make extra changes to the DITA OT which might explain this problem?
One more question, what Ant installation are you using? Did you bundle "Apache Ant" with your plugin or do you use Oxygen's bundled Apache Ant from its "OXYGEN_INSTALL_DIR\tools\ant" folder? Or do you rely on the fact that all users have Apache Ant pre-installed in their system?

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

wmaclean
Posts: 38
Joined: Sat Jan 04, 2020 1:17 am

Re: newlines not working in <codeblock> tags

Post by wmaclean » Wed Jan 13, 2021 7:39 pm

Hi Radu,
Thanks very much for your thoughts! I will use them, if my current hunch is wrong.

At the moment, I suspect that the Java class DocumentBuilder parsing we use is somehow removing newlines. Which is also outside of Oxygen.

You and your team have been very helpful so many times...
Thanks a ton for all you've done!

Will

wmaclean
Posts: 38
Joined: Sat Jan 04, 2020 1:17 am

Re: newlines not working in <codeblock> tags

Post by wmaclean » Wed Jan 13, 2021 11:46 pm

Hello again Radu,
I'm sorry to bother you again on this, but would you know offhand how Oxygen represents newline in a <codeblock> in an xml file?

I am experimenting with trying to convert newlines to an escape character, to see if it will make it past the parser.

What I've tried so far:

&#13;
&#x13&#x10;
\n
\r\n
&#x10;

If you don't know offhand, no worries.

Thanks much,
Will

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

Re: newlines not working in <codeblock> tags

Post by Radu » Thu Jan 14, 2021 8:23 am

Hi Will,

Usually new lines are represented with the "\n" character which is visually shown as a line break in any editor, including Oxygen. It's equivalent entity reference notations are "&#10;" (decimal 10) and "&#xa;" (hexadecimal A) but they are equivalent, so you can use either one but the output should look the same.
Coming back to your problem, I think it may occur because you are running ANT but you are not specifying to the "ant" process a set of Java JAR libraries to load so it probably does not load the JAR libraries from the "DITA-OT\lib" folder. You are using a very old version of the DITA-OT. Back then you needed to run a "startcmd.bat" and in the command line which opened up you needed to run the Ant command:

http://dita-ot.sourceforge.net/1.8/

So I'm not sure if you are doing the equivalent of that in your plugin, the equivalent probably being that when the Java process is started you need to pass to it environmental variables similar to what the "DITA-OT\startcmd.bat" contains.

Or the problem might occur because of a custom publishing plugin which treats the content of codeblocks incorrectly in the XSLT code.

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

Post Reply