Skip to content

HTML tag LI align not working #2304

@mivart

Description

@mivart

Describe the Bug

LI tag with inline style ""text-align:justify" does not justify text inside LI element.

Steps to Reproduce

<ol>
	<li style="text-align:justify;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam..</li>
</ol>

Possible solution

/PhpWord/Shared/Html.php

    protected static function parseListItem($node, $element, &$styles, $data)
    {
        $cNodes = $node->childNodes;
        if (!empty($cNodes)) {
            
             /*FIX issue with incorrect style parsing  of LI element*/
             $styles['paragraph'] = self::recursiveParseStylesInHierarchy($node, $styles['paragraph']);
            /**/

            $listRun = $element->addListItemRun($data['listdepth'], $styles['list'], $styles['paragraph']);
            foreach ($cNodes as $cNode) {
                self::parseNode($cNode, $listRun, $styles, $data);
            }
        }
    }

Context

  • PHP Version: 7.3.1
  • PHPWord Version: 0.18.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions