Adding Syntax Highlights for Codeblocks

Post here questions and problems related to editing and publishing DITA content.
kate_lopresti
Posts: 14
Joined: Tue Aug 08, 2023 2:43 am

Adding Syntax Highlights for Codeblocks

Post by kate_lopresti »

I'm testing syntax highlights for codeblocks using predefined @outputclass attribute values:

Code: Select all

<codeblock id="codeblock_xpj_fjj_42c" outputclass="language-python">
# This program prints Hello, world!
print('Hello, world!')
        </codeblock>
However, using the DITA HTML5 and DITA XHTML transformation scenarios, the output is black and white. Is there something I need to add to the scenario?
test_html5.png
test_xhtml.png
https://www.oxygenxml.com/doc/versions/ ... cks-x.html
You do not have the required permissions to view the files attached to this post.
julien_lacour
Posts: 665
Joined: Wed Oct 16, 2019 3:47 pm

Re: Adding Syntax Highlights for Codeblocks

Post by julien_lacour »

Hello,

Syntax higtlight is available for both HTML5 and XHTML outputs, as you can see below:
image.png
(tested using <oXygen/> XML Editor 27.0, build 2024121306)

Make sure Oxygen > Options > Preferences... > DITA > DITA Open Toolkit is set to "Built-in Oxygen Publishing Engine (based on DITA-OT 4.x)" and not a custom DITA-OT.
The emphasized elements are given by a custom Oxygen plugin not available on vanilla DITA-OT versions.

The highlight colors are given by the com.oxygenxml.webhelp.responsive/src/main/app/topic/syntax-highlight.css stylesheet contained in the WebHelp Responsive plugin. You can copy it and refer it in your HTML transformation(s) using args.css parameter (make sure to also enable args.copycss in order to copy the stylesheet into the output directory).

Regards,
Julien
You do not have the required permissions to view the files attached to this post.
kate_lopresti
Posts: 14
Joined: Tue Aug 08, 2023 2:43 am

Re: Adding Syntax Highlights for Codeblocks

Post by kate_lopresti »

Sure enough, I was pointing to a custom DITA-OT. Thanks for the correction.
Post Reply