Skip to content

Core: Preserve Markdown URLs during translation - #509

Draft
Minseok Song (skytin1004) wants to merge 1 commit into
Azure:mainfrom
skytin1004:fix/markdown-url-preservation
Draft

Core: Preserve Markdown URLs during translation#509
Minseok Song (skytin1004) wants to merge 1 commit into
Azure:mainfrom
skytin1004:fix/markdown-url-preservation

Conversation

@skytin1004

@skytin1004 Minseok Song (skytin1004) commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Prevent translation providers and path rewriting from modifying URLs in Markdown links and images.

Description

Markdown link destinations were sent directly to the translation model. Although the prompt instructed the model to preserve URLs, a live translation changed WT.mc_id to WT_mc_id in several links.

This change:

  • uses markdown-it's existing link/image rules and destination parser to locate non-anchor inline Markdown destinations
  • replaces those destinations with placeholders before translation and restores them exactly afterward
  • applies the same protection to provider-backed and agent-assisted translation flows
  • preserves query strings and fragments when Markdown and HTML image paths are rewritten
  • adds regression tests for URL mutation, nested image links, escaped syntax, and image URL suffixes

Internal #anchor destinations remain visible so they can still be aligned with translated heading slugs.

Related Issue

Follow-up to #508.

Does this introduce a breaking change?

Will this change require users to update commands, configuration, environment variables, generated translation output, or public Python/MCP APIs?
If you're not sure, test the affected CLI, API, documentation, or GitHub Actions workflow before marking this as "No."

  • Yes
  • No

Type of change

  • Bugfix
  • Feature
  • Code style update (e.g., formatting, local variables)
  • Refactoring (no functional or API changes)
  • Documentation content changes
  • Other... Please describe:

Checklist

Before submitting your pull request, please confirm the following:

  • I have thoroughly tested my changes: I confirm that I have run the code and manually tested all affected areas.
  • All existing tests pass: I have run all tests and confirmed that nothing is broken.
  • I have added new tests (if applicable): I have written tests that cover the new functionality introduced by my code changes.
  • I have followed the Co-op Translator coding conventions: My code adheres to the style guide and coding conventions outlined in the repository.
  • I have documented my changes (if applicable): I have updated the documentation to reflect the changes where necessary.

Additional context

All 332 non-API tests pass, and Ruff and Black checks pass. I also verified the affected generative-ai-for-beginners README with a live Azure OpenAI translation: all 121 external URLs and all 105 WT.mc_id parameters were preserved, with no modified URLs or unresolved placeholders.

@github-actions github-actions Bot added core Related to any changes in core source files tests labels Aug 9, 2026
@skytin1004
Minseok Song (skytin1004) force-pushed the fix/markdown-url-preservation branch from 3663475 to ed7d6ed Compare August 9, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Related to any changes in core source files tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant