Skip to content

Commit

Permalink
feat: Allow for paragraphs in comment (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinderVosDeWael authored Dec 18, 2024
1 parent f91cfec commit dc811f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
44 changes: 22 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "cmi-docx"
version = "0.3.6"
description = "Additional tooling for Python-docx."
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"python-docx>=1.1.2"
]

[tool.uv]
dev-dependencies = [
"mypy>=1.13.0",
"pre-commit>=4.0.1",
"pytest>=8.3.4",
"pytest-cov>=6.0.0",
"ruff>=0.8.3",
"pdoc>=15.0.1"
]

[tool.hatch.build.targets.wheel]
packages = ["src/cmi_docx"]
Expand Down Expand Up @@ -67,22 +83,6 @@ indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.uv]
dev-dependencies = [
"mypy>=1.13.0",
"pre-commit>=4.0.1",
"pytest>=8.3.4",
"pytest-cov>=6.0.0",
"ruff>=0.8.3",
"pdoc>=15.0.1"
]

[project]
name = "cmi-docx"
version = "0.3.5"
description = "Additional tooling for Python-docx."
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"python-docx>=1.1.2"
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
18 changes: 9 additions & 9 deletions src/cmi_docx/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ def add_comment(
comment_element.set(ns.qn("w:date"), datetime.datetime.now().isoformat())

# Create the text element for the comment
comment_paragraph = oxml.OxmlElement("w:p")
comment_run = oxml.OxmlElement("w:r")
comment_text_element = oxml.OxmlElement("w:t")
comment_text_element.text = text
comment_run.append(comment_text_element)
comment_paragraph.append(comment_run)
comment_element.append(comment_paragraph)

comments_xml.append(comment_element)
for para in text.split("\n"):
comment_paragraph = oxml.OxmlElement("w:p")
comment_run = oxml.OxmlElement("w:r")
comment_text_element = oxml.OxmlElement("w:t")
comment_text_element.text = para
comment_run.append(comment_text_element)
comment_paragraph.append(comment_run)
comment_element.append(comment_paragraph)
comments_xml.append(comment_element)
comments_part._blob = ElementTree.tostring(comments_xml)

# Create the commentRangeStart and commentRangeEnd elements
Expand Down

0 comments on commit dc811f3

Please sign in to comment.