Merge pull request #1539 from GautierDele/develop

Update documentation on usage of ListItemRun
This commit is contained in:
troosan 2018-12-26 14:35:42 +01:00 committed by GitHub
commit 56ca30ab95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -61,7 +61,7 @@ Legend:
Texts Texts
----- -----
Text can be added by using ``addText`` and ``addTextRun`` method. Text can be added by using ``addText`` and ``addTextRun`` methods.
``addText`` is used for creating simple paragraphs that only contain texts with the same style. ``addText`` is used for creating simple paragraphs that only contain texts with the same style.
``addTextRun`` is used for creating complex paragraphs that contain text with different style (some bold, other ``addTextRun`` is used for creating complex paragraphs that contain text with different style (some bold, other
italics, etc) or other elements, e.g. images or links. The syntaxes are as follow: italics, etc) or other elements, e.g. images or links. The syntaxes are as follow:
@ -155,13 +155,18 @@ method or using the ``pageBreakBefore`` style of paragraph.
Lists Lists
----- -----
To add a list item use the function ``addListItem``. Lists can be added by using ``addListItem`` and ``addListItemRun`` methods.
``addListItem`` is used for creating lists that only contain plain text.
``addListItemRun`` is used for creating complex list items that contains texts
with different style (some bold, other italics, etc) or other elements, e.g.
images or links. The syntaxes are as follow:
Basic usage: Basic usage:
.. code-block:: php .. code-block:: php
$section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]); $section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]);
$listItemRun = $section->addListItemRun([$depth], [$listStyle], [$paragraphStyle])
Parameters: Parameters:
@ -172,6 +177,8 @@ Parameters:
TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem. TYPE\_ALPHANUM, TYPE\_BULLET\_FILLED, etc. See list of constants in PHPWord\\Style\\ListItem.
- ``$paragraphStyle``. See :ref:`paragraph-style`. - ``$paragraphStyle``. See :ref:`paragraph-style`.
See ``Sample_09_Tables.php`` for more code sample.
Advanced usage: Advanced usage:
You can also create your own numbering style by changing the ``$listStyle`` parameter with the name of your numbering style. You can also create your own numbering style by changing the ``$listStyle`` parameter with the name of your numbering style.

View File

@ -64,7 +64,7 @@ $section->addText('List with inline formatting.');
$listItemRun = $section->addListItemRun(); $listItemRun = $section->addListItemRun();
$listItemRun->addText('List item 1'); $listItemRun->addText('List item 1');
$listItemRun->addText(' in bold', array('bold' => true)); $listItemRun->addText(' in bold', array('bold' => true));
$listItemRun = $section->addListItemRun(); $listItemRun = $section->addListItemRun(1, $predefinedMultilevelStyle, $paragraphStyleName);
$listItemRun->addText('List item 2'); $listItemRun->addText('List item 2');
$listItemRun->addText(' in italic', array('italic' => true)); $listItemRun->addText(' in italic', array('italic' => true));
$footnote = $listItemRun->addFootnote(); $footnote = $listItemRun->addFootnote();