Repository navigation
Conversation
…DOCX import `_run_to_markdown` wrapped a formatted Word run as is, so a bold run "Hello " followed by "world" imported as `**Hello **world`. CommonMark does not close `**` after a space, so the asterisks showed as literal text. Word bolds a word together with its trailing space all the time, and the same broke italic, bold-italic and strikethrough runs; a formatted run of only spaces became `** **`. The markers now wrap only the run's non-space core and the edge whitespace goes back outside (`**Hello** world`); a whitespace-only run is emitted as plain spaces. Unformatted and code-font runs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
XAE-A-Xii
force-pushed
the
fix/docx-emphasis-whitespace
branch
from
December 5, 2026 12:15
a892891 to
efd9072
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Importing a Word document produced emphasis that Markdown doesn't render.
_run_to_markdown(deeptutor/co_writer/docx_converter.py) wrapped each formatted run as is, and Word routinely includes the trailing space in a bold or italic run. A document built with python-docx (bold"Hello "+"world", and so on) imported as:CommonMark doesn't close
**,*or~~after a space. Checked withmarkdown-it-py(commonmark + strikethrough):The markers now wrap only the run's non-space core, and the edge whitespace goes back outside:
**Hello** world,*Note:* x,a ***both*** b,old ~~price~~ new. A formatted run that is only spaces is emitted as plain spaces (gap here). Unformatted runs come out byte-identical, and code-font runs are untouched (inside backticks the spaces are significant).Related Issues
Module(s) Affected
agentsapiconfigcoreknowledgeloggingservicestoolsutilsweb(Frontend)docs(Documentation)scriptstestsco_writerChecklist
dev(notmain— see the base-branch selector above).pre-commit run --all-filesand fixed any issues.Additional Notes
tests/co_writer/test_docx_import_emphasis_whitespace.pybuilds real.docxfiles with python-docx and runsdocx_to_markdown. The existing DOCX emphasis tests only cover export. The cases are trailing space (bold, italic, bold-italic, strikethrough), leading space, a whitespace-only bold run, and a plain bold word as a regression guard.Before the fix, 6 of the 7 cases fail; only the plain bold word passes. Mutations are caught too: dropping the whitespace-only guard fails 1 case, and putting the leading space after the core fails 2.
pre-commit run --fileson both changed files passes every hook (ruff, mypy, bandit, detect-secrets). Note thatpre-commit run --all-filescurrently failsmypyondevitself indeeptutor/services/embedding/adapters/volcengine.py, from #1015, which this PR doesn't touch.🤖 Generated with Claude Code