How to prevent line breaks with "codeblock"?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Carl
Posts: 102
Joined: Fri Oct 19, 2018 2:19 am

How to prevent line breaks with "codeblock"?

Post by Carl »

How do I prevent a line break within a codeblock paragraph in my PDF?

I was searching for an equivalent to Word's "Keep lines together" option, but I can't find one.
julien_lacour
Posts: 495
Joined: Wed Oct 16, 2019 3:47 pm

Re: How to prevent line breaks with "codeblock"?

Post by julien_lacour »

Hello,

You should be able to do the trick by using the following CSS selector:

Code: Select all

*[class~='pr-d/codeblock'] {
    page-break-inside:avoid;
}
Regards,
Julien
Carl
Posts: 102
Joined: Fri Oct 19, 2018 2:19 am

Re: How to prevent line breaks with "codeblock"?

Post by Carl »

Thanks for the info. Now I'm having a difficult time trying to identify which ".css" file to add this code snippet.

Is there a default .css that Oxygen uses for PDF? Or do I need to create a new custom .css for PDF?
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: How to prevent line breaks with "codeblock"?

Post by chrispitude »

Carl wrote: Fri Aug 14, 2020 9:15 pm Thanks for the info. Now I'm having a difficult time trying to identify which ".css" file to add this code snippet.

Is there a default .css that Oxygen uses for PDF? Or do I need to create a new custom .css for PDF?
To get started, you can create a my.css file in the root of your project directory with only that property.

If you're using the default "DITA Map PDF - based on HTML5 & CSS" transformation, make a duplicate of it so you can edit the settings.

Now set the args.css parameter to ${pdu}/my.css:

image.png
image.png (43.45 KiB) Viewed 1361 times
Post Reply