diff --git a/pyproject.toml b/pyproject.toml index dd5a6b6..1d8c0dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] @@ -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" diff --git a/src/cmi_docx/comment.py b/src/cmi_docx/comment.py index 0ff216d..916ce06 100644 --- a/src/cmi_docx/comment.py +++ b/src/cmi_docx/comment.py @@ -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