Bug 515330 - Markdown code blocks are not syntax highlighted in rendered preview
Summary: Markdown code blocks are not syntax highlighted in rendered preview
Status: REPORTED
Alias: None
Product: markdownpart
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Friedrich W. H. Kossebau
URL:
Keywords: qt6, usability
Depends on:
Blocks:
 
Reported: 2026-01-31 07:48 UTC by Ricardo
Modified: 2026-01-31 07:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ricardo 2026-01-31 07:48:44 UTC
SUMMARY
Markdown code blocks are not syntax highlighted in rendered preview

STEPS TO REPRODUCE
1. Open any Markdown file containing fenced code blocks with language specifiers (e.g., ```bash, ```python, ```javascript)
2. View the rendered Markdown preview using markdownpart (in Kate, Ghostwriter, KleverNotes, ReText, or any KParts-based application)
3. Observe the code blocks in the preview

OBSERVED RESULT
Code blocks appear in monospace font but without any syntax highlighting. All code text is displayed in the same color regardless of the specified language.

EXPECTED RESULT
Code blocks should be syntax highlighted according to the language specified in the fence (```bash, ```python, etc.), using KSyntaxHighlighting framework or similar to apply appropriate colors to keywords, strings, comments, and other language elements.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux (kernel 6.12.10)
KDE Plasma Version: 6.5.5
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.1
markdownpart Version: 25.12.1-1

ADDITIONAL INFORMATION
Investigation shows that markdownpart uses libmd4c for Markdown parsing but does not link against KSyntaxHighlighting or any other syntax highlighting library (verified with ldd). The generated HTML contains plain <code> tags without highlighting classes or inline styles.

KDE already has the necessary infrastructure for syntax highlighting (KSyntaxHighlighting framework with definitions in /usr/share/org.kde.syntax-highlighting/syntax-bundled/), which is used successfully in Kate's editor view. Integrating this into markdownpart would provide consistent, high-quality syntax highlighting for code blocks in Markdown previews across all KParts-based applications.

This affects user experience when viewing technical documentation, code snippets, or any Markdown content with code examples in Kate, Ghostwriter, KleverNotes, ReText, and other KDE applications that use markdownpart.

Related resources:
- KSyntaxHighlighting framework: https://api.kde.org/frameworks/syntax-highlighting/html/
- CommonMark spec on fenced code blocks: https://spec.commonmark.org/0.31.2/#fenced-code-blocks