Title: add_comment() references the "CommentReference" character style without defining it · Issue #1609 · python-openxml/python-docx · GitHub
Open Graph Title: add_comment() references the "CommentReference" character style without defining it · Issue #1609 · python-openxml/python-docx
X Title: add_comment() references the "CommentReference" character style without defining it · Issue #1609 · python-openxml/python-docx
Description: Document.add_comment() (via Run.mark_comment_range) writes the comment reference run with rStyle w:val="CommentReference", but nothing adds that style to styles.xml. A default Document() template doesn't contain it either. Word and Libre...
Open Graph Description: Document.add_comment() (via Run.mark_comment_range) writes the comment reference run with rStyle w:val="CommentReference", but nothing adds that style to styles.xml. A default Document() template d...
X Description: Document.add_comment() (via Run.mark_comment_range) writes the comment reference run with rStyle w:val="CommentReference", but nothing adds that style to styles.xml. A default Document() ...
Opengraph URL: https://github.com/python-openxml/python-docx/issues/1609
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"add_comment() references the \"CommentReference\" character style without defining it","articleBody":"`Document.add_comment()` (via `Run.mark_comment_range`) writes the comment reference run with `rStyle w:val=\"CommentReference\"`, but nothing adds that style to `styles.xml`. A default `Document()` template doesn't contain it either. Word and LibreOffice both tolerate a dangling `rStyle` silently and format the reference mark with the run's default properties instead of the built-in 8pt \"annotation reference\" style, so the mark just looks slightly wrong with no warning anywhere.\n\nRepro, python-docx 1.2.0:\n\n from docx import Document\n import zipfile\n\n d = Document()\n p = d.add_paragraph(\"The fee is EUR 12,000 per milestone.\")\n d.add_comment(runs=p.runs[0], text=\"Confirm this figure\", author=\"Reviewer\")\n d.save(\"out.docx\")\n\n z = zipfile.ZipFile(\"out.docx\")\n doc = z.read(\"word/document.xml\").decode()\n sty = z.read(\"word/styles.xml\").decode()\n print('rStyle in document.xml:', doc.count('w:val=\"CommentReference\"'))\n print('style defined in styles.xml:', sty.count('w:styleId=\"CommentReference\"'))\n\n # rStyle in document.xml: 1\n # style defined in styles.xml: 0\n\nSuggested fix: when adding a comment, add the style definition if the document lacks it. What Word writes is:\n\n \u003cw:style w:type=\"character\" w:styleId=\"CommentReference\">\n \u003cw:name w:val=\"annotation reference\"/>\n \u003cw:basedOn w:val=\"DefaultParagraphFont\"/>\n \u003cw:uiPriority w:val=\"99\"/>\n \u003cw:semiHidden/>\u003cw:unhideWhenUsed/>\n \u003cw:rPr>\u003cw:sz w:val=\"16\"/>\u003cw:szCs w:val=\"16\"/>\u003c/w:rPr>\n \u003c/w:style>\n\nAlternatively, omit the `rStyle` altogether when the style isn't defined — a reference mark with default formatting is at least self-consistent.\n\nFiling this separately per the discussion in #1605. The same gap existed in adeu and was fixed in their 3.0.3.\n\npython-docx 1.2.0, Python 3.9.6, macOS","author":{"url":"https://github.com/Dmitry-Kov","@type":"Person","name":"Dmitry-Kov"},"datePublished":"2026-09-09T06:25:13Z","url":"https://github.com/python-openxml/python-docx/issues/1609"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:43fe4a99-9a5e-4f22-ba8a-09fa1ab3130f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC6A:2A971:2494F0:30BA21:6AFF638C |
| html-safe-nonce | 3e48a7760ca9438c042004c29f3d8679149bc3dc4d4bb71dc710165c411a2a4d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzZBOjJBOTcxOjI0OTRGMDozMEJBMjE6NkFGRjYzOEMiLCJ2aXNpdG9yX2lkIjoiOTE0ODE4NjY2OTAzODM5NjMwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 53667b52d185236f126e5460ae806fdc4944159b3c93b5171ee73ea9fc33d0e6 |
| hovercard-subject-tag | issue:5395820230 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-openxml/python-docx/1609/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7bf7834828021e79798b1f3c00ee87f093711fc5e48bb2cd9648d70154d99764/python-openxml/python-docx/issues/1609 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7bf7834828021e79798b1f3c00ee87f093711fc5e48bb2cd9648d70154d99764/python-openxml/python-docx/issues/1609 |
| og:image:alt | Document.add_comment() (via Run.mark_comment_range) writes the comment reference run with rStyle w:val="CommentReference", but nothing adds that style to styles.xml. A default Document() template d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Dmitry-Kov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b58589a1c4eda1e3c8904144a412b88ca4455f63ca2ad3629f2e9f3c3a1d12 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openxml/python-docx git https://github.com/python-openxml/python-docx.git |
| octolytics-dimension-user_id | 3403760 |
| octolytics-dimension-user_login | python-openxml |
| octolytics-dimension-repository_id | 13592924 |
| octolytics-dimension-repository_nwo | python-openxml/python-docx |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13592924 |
| octolytics-dimension-repository_network_root_nwo | python-openxml/python-docx |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8968d6d6acc65d74e4df332d23932dd3fd0502a4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width