Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why don't you expose $styles on HTML parser for the meantime? #417

Open
twmobius opened this issue Nov 10, 2014 · 1 comment
Open

Why don't you expose $styles on HTML parser for the meantime? #417

twmobius opened this issue Nov 10, 2014 · 1 comment

Comments

@twmobius
Copy link

twmobius commented Nov 10, 2014

By reading the source code in \PhpWord\Shared\Html I understand that you are planning on getting the stylesheets from the inline style="" tag, which could be good to begin with but comes sort when it comes to existing content that makes use of css classes.

In the meantime if you could change this:

public static function addHtml($element, $html, $fullHTML = false)

to this

public static function addHtml($element, $html, $fullHTML = false, $styles = array()) {

and accordingly pass $styles down to self::parseNode($node->item(0), $element, $styles); you would make it possible to have stylesheets on the html reading like so:

\PhpWord\Shared\Html::addHtml($section, $article->getBody(), false, array(
          'paragraph' => array(
            'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6),
            'align'      => 'justify',
            'lineHeight' => 1.5
          )
     )
);

I would suggest taking a look at dompdf (https://github.com/dompdf/dompdf) and especially at (https://github.com/dompdf/dompdf/blob/c3527d98d03e61847bd25f9e5cedf86dcc46bebf/include/stylesheet.cls.php) which actually parses a css file or a script tag.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@github-actions github-actions bot added the Stale label Nov 18, 2022
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants