Page 1 of 1
Adding Syntax Highlights for Codeblocks
Posted: Tue Mar 04, 2025 9:25 pm
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
Re: Adding Syntax Highlights for Codeblocks
Posted: Wed Mar 05, 2025 12:58 pm
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
Re: Adding Syntax Highlights for Codeblocks
Posted: Fri Mar 07, 2025 4:01 am
by kate_lopresti
Sure enough, I was pointing to a custom DITA-OT. Thanks for the correction.