Skip to content

Commit

Permalink
Documentation : Updated Comment element (#2650)
Browse files Browse the repository at this point in the history
Fix error on comments code snippet.

Co-authored-by: laminga <39699385+laminga@users.noreply.github.com>
  • Loading branch information
Progi1984 and laminga authored Aug 12, 2024
1 parent 997a829 commit fbe52dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changes/2.x/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- 32-bit Problem in PasswordEncoder [@oleibman](https://github.com/oleibman) fixing [#2550](https://github.com/PHPOffice/PHPWord/issues/2550) in [#2551](https://github.com/PHPOffice/PHPWord/pull/2551)
- Typo : Fix hardcoded macro chars in TemplateProcessor method [@glafarge](https://github.com/glafarge) in [#2618](https://github.com/PHPOffice/PHPWord/pull/2618)
- XML Reader : Prevent fatal errors when opening corrupt files or "doc" files [@mmcev106](https://github.com/mmcev106) in [#2626](https://github.com/PHPOffice/PHPWord/pull/2626)
- Documentation : Updated Comment element by [@laminga](https://github.com/laminga) in [#2650](https://github.com/PHPOffice/PHPWord/pull/2650)

### Miscellaneous

Expand Down
7 changes: 4 additions & 3 deletions docs/usage/elements/comment.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Comment

Comments can be added to a document by using ``addComment``.
The comment can contain formatted text. Once the comment has been added, it can be linked to any element with ``setCommentStart``.
The comment can contain formatted text. Once the comment has been added, it can be linked to any element with ``setCommentRangeStart``.

``` php
<?php
Expand All @@ -17,7 +17,8 @@ $textrun = $section->addTextRun();
$textrun->addText('This ');
$text = $textrun->addText('is');
// link the comment to the text you just created
$text->setCommentStart($comment);
$text->setCommentRangeStart($comment);
$textrun->addText(' a test');
```

If no end is set for a comment using the ``setCommentEnd``, the comment will be ended automatically at the end of the element it is started on.
If no end is set for a comment using the ``setCommentRangeEnd``, the comment will be ended automatically at the end of the element it is started on.

0 comments on commit fbe52dc

Please sign in to comment.