-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Enhancements to addHTML parser #1902
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
Conversation
fix image alignment on float - relative to inner margin instead of page margin
There is 1 failing job - not sure what to do about it, does not seem related and repeatedly shows up with other PRs. Log:
|
Is this repo dead? No feedback since 3 weeks ago ... ? |
pr PHPOffice#1902 on original repo
What's up with this PR? This adds some good features :| |
If you need a quick enhancement, you may want to use composer repo This repo looks truly like abandoned, even though not officially. Probably time & money issue, like with most open sources .. |
@troosan |
@lubosdz feel free to create another PR with those changes. I won't be merging them in this release though, it's been waiting for a long time :-) |
Description
Currently importing HTML via
PhpWord\Shared\Html::addHtml()
has couple of bugs and misses support for some at least basic HTML tags & attributes. This PR attempts to fix these issues without BC break (at least no existing unit test break):Fixed legacy issues:
width
property into cells, allowing also to control colum widths inside tables. Following would currently not workstyle="width: 35%"
- because width is passed as a wrong argument. Once fixed, it will also allow to control columns width inside tables. Since all widths are currently ignored (not recognized) they are set towidth = "auto"
.twips
. Currently passing 10px results into 7.5 twips therefore value is seemingly ignored, unless users sets some absurd value likewidth: 600px
.New enhancements:
<td width="25%">
<table cellspacing="3">
border-*
variants e.g.border-bottom: 1px #DDDDDD solid;
(top, right, left, bottom) - useful for tables & cells<tr bgColor="#DDDDDD">
<hr />
with limited custom styling<th valign="bottom">
orstyle="vertical-align: middle;"
<ol type="A" start="3">
Checklist:
composer run-script check --timeout=0
and no errors were reportedMore enhancements possible (with BC break)
A two more fixes should be fixed to make current method
addHtml()
more usable and compatible:cell property inheritance
- currently all elements always inherit all properties from parent node. This however should not apply to cells. Cells should not inherit most of parent properties e.g. borders, margins etc. because it produces unexpected output. In spite of BC break this should be fixed ASAP. Current behaviour is quite incompatible with legacy HTML output. Moreover, inheriting widths from parent nodes causes unpredictable results in table layouts.<h1> .. <h6>
out of the box. Current implementation relies that user will somewhere define his own heading styleHeading1
,Heading2
etc., which adds extra code boilerplate for developers and also requires to study how to do that (increases learning curve). Since H1 .. H6 are very basic elements in any HTML, these should work out of the box.Unfortunatelly, both improvements above will cause BC break, and therefore have been excluded from this PR in order to make space for discussion.