Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Whitespace after toRichTextObject() + fix #554

Closed
xairoo opened this issue May 5, 2015 · 1 comment
Closed

Whitespace after toRichTextObject() + fix #554

xairoo opened this issue May 5, 2015 · 1 comment

Comments

@xairoo
Copy link

xairoo commented May 5, 2015

Using toRichTextObject() to encode a HTML string:

<strong>bold</strong>, <em>italic</em>, <strong><em>bold+italic</em></strong>

becomes:
bold , italic , _bold+italic_

I fixed this for me:
@PHPExcel/Classes/PHPExcel/Helper/HTML.php

    protected function parseElementNode(DOMElement $element) {
        $callbackTag = strtolower($element->nodeName);
        $this->stack[] = $callbackTag;

        $this->handleCallback($element, $callbackTag, $this->startTagCallbacks);

        $this->parseElements($element);
        $this->stringData .= ' ';
        array_pop($this->stack);

        $this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
    }

Should be:

        $this->stringData .= ''; // whitespace removed
@MarkBaker
Copy link
Member

This space is necessary in some cases, simply removing it may merge words together.... e.g. in the 42richText.php example, it removes the space between h2so4 and is and between 2<sup>3</sup> andequals`.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants