Skip to content

Conversation

@javierbrea
Copy link
Collaborator

@javierbrea javierbrea commented Nov 24, 2025

Add code blocks transformation to Confluence code macro

Description

Implements proper rendering of markdown code blocks in Confluence by converting them to structured code macros with syntax highlighting support. This addresses issue #65 where code blocks were appearing as inline text instead of formatted code blocks.

Changes

  • Added new rehype-replace-code-blocks plugin to transform <pre><code> elements to Confluence's code macro format
  • Added rehype.codeBlocks configuration option (default: false) to enable/disable the feature for compatibility with older Confluence versions
  • Comprehensive unit tests with 10 test cases covering various scenarios (empty blocks, multiple languages, special characters, etc.)
  • Updated documentation in README.md with configuration details and examples
  • Updated CHANGELOG.md under "unreleased" section
  • Bumped package version to 2.3.0 (MINOR version per semantic versioning)

Implementation Details

The plugin:

  • Converts markdown fenced code blocks to Confluence's <ac:structured-macro ac:name="code"> format
  • Preserves language syntax highlighting information from code fence language identifiers
  • Handles edge cases: empty blocks, blocks without language specification, special characters, multi-line code
  • Is enabled by default but can be disabled via configuration for older Confluence instances

Test Plan

  • All existing unit tests pass
  • New unit tests added and passing (10 comprehensive tests)
  • Linting checks pass
  • TypeScript compilation successful
  • Feature follows existing plugin patterns in the codebase

Closes #65

Agreement

Please check the following boxes after you have read and understood each item.

  • I have read the CONTRIBUTING document
  • I have read the CODE_OF_CONDUCT document
  • I accept that, by signing the Contributor License Agreement through a comment in the PR, my Github user name will be stored by in a branch of this repository for future reference.

In case this is your first contribution to this project, you will also have to add a comment with the following text: "I have read the CLA Document and I hereby sign the CLA", otherwise the PR status will fail and our bot will request you to add it. Once you have signed it in a PR, you will not have to sign it again for future contributions.

FrankLedo and others added 17 commits November 13, 2025 09:36
Implements proper rendering of markdown code blocks in Confluence by
converting them to structured code macros with syntax highlighting.
This addresses issue #65 where code blocks were appearing as inline
text instead of formatted code blocks. The feature is enabled by
default and can be disabled for compatibility with older Confluence
versions via the confluence.rehype.codeBlocks configuration option.
…alse

- Move codeBlocks from confluence.rehype.codeBlocks to top-level configuration
- Change default value from true to false for backward compatibility
- Update documentation to reflect new configuration structure

This addresses PR feedback to align configuration structure with
architectural boundaries and ensure backward compatibility with older
Confluence versions that don't support code macros through the API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…macro

feat: Add code blocks transformation to Confluence code macro
@javierbrea javierbrea self-assigned this Nov 24, 2025
Copilot AI review requested due to automatic review settings November 24, 2025 07:14
@github-actions
Copy link

github-actions bot commented Nov 24, 2025

Check SPDX headers

✅ 247 files have valid headers.

@github-actions
Copy link

github-actions bot commented Nov 24, 2025

Check License Compliance

✅ There are 1450 dependencies with allowed licenses.

⚠️ There are 5 dependencies with dangerous licenses:

✅ Result: Valid licenses

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for transforming markdown code blocks into Confluence's structured code macro format with syntax highlighting. The feature is disabled by default for backward compatibility with older Confluence versions and can be enabled via the rehype.codeBlocks configuration option.

Key Changes:

  • Added rehype-replace-code-blocks plugin to convert <pre><code> elements to Confluence code macros
  • Added rehype.codeBlocks configuration option (default: false)
  • Comprehensive test suite with 10 test cases covering various scenarios

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rehype-replace-code-blocks.test.ts Comprehensive unit tests for the new code blocks transformation plugin
ConfluencePageTransformer.test.ts Updated existing tests to include the new rehype configuration
ConfluenceSync.test.ts Added rehype config namespace to test setup
rehype-replace-code-blocks.ts Core plugin implementation for transforming code blocks
ConfluencePageTransformer.types.ts Added type definitions for rehype options
ConfluencePageTransformer.ts Integrated the code blocks plugin with conditional enabling
ConfluenceSync.types.ts Added type definitions for the rehype codeBlocks option
ConfluenceSync.ts Implemented the codeBlocks option and passed it to transformer
MarkdownConfluenceSync.ts Added rehype configuration namespace
package.json Version bump to 2.3.0
markdown-confluence-sync.config.cjs Example configuration with codeBlocks enabled
README.md Documentation for the new feature
CHANGELOG.md Release notes for version 2.3.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@javierbrea javierbrea merged commit be9c662 into release Nov 24, 2025
11 checks passed
@javierbrea javierbrea deleted the feat/65/rehype-codeblocks branch November 24, 2025 09:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants