Skip to content

Add support for various missing features in HTML Writer #1814

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

Closed
wants to merge 21 commits into from
Closed

Add support for various missing features in HTML Writer #1814

wants to merge 21 commits into from

Conversation

oleibman
Copy link
Contributor

@oleibman oleibman commented Feb 3, 2020

Description

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.

Testing change from Pull Request 1771 is included here, but was
merged after my fork.

Fixes # (issue)

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

    1. Use css @page and page declarations for sections.
    2. Wrap sections in div, with page break before each (except first).
    3. Add ability to specify generic fallback font for html (documentation change).
    4. Add ability to specify handling of whitespace in html (documentation change).
       Currently, Word writer preserves space but HTML writer does not.
    5. Support for Language, both for document overall and individual text elements.
    6. Support for PageBreak for HTML (currently only PDF is supported).
    7. Support for Table Border style, color, and size.
    8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
    9. Default paragraph style should apply to all paragraphs, as well as class Normal.
    10. Paragraph style should support line-height.
    11. Paragraph style should support indentation.
    12. Paragraph style should support page-break-before.
    13. Paragraph style should not specify margin-top/bottom when spacing is null.

Testing change from Pull Request 1771 is included here, but was
merged after my fork.
@coveralls
Copy link

coveralls commented Feb 3, 2020

Coverage Status

Coverage increased (+0.09%) to 94.727% when pulling 192e2ba on oleibman:htmlchanges into 733f845 on PHPOffice:develop.

Mostly docblock changes, specifying that members can be null if so.
Hopefully this clears 3 remaining issues.
Reaction to Coveralls report.
I had been overriding some "false positive" Scrutinizer messages
with annotations. Seeing if an alternate approach also works.
New issue after removing annotations.
Zend/Escaper is no longer maintained. However, everything that
it does can be handled perfectly well by htmlspecialchars.
This change removes the dependency on it, and changes code which used it.

Also add additional tests. Coverage of Writer/HTML is now 100%
Scrutinizer reported a problem because Title->getText() was annotated to return a string,
but it can actually return either a string or a TextTun.
Change one statement in Writer/HMTL/Title
See issue #1993. The code currently defines the same method twice; this edit fixes that.
This member was NOT part of my change, yet Travis failed my PR because of use of spaces on a blank line. Even though this is easy to correct, it seems very unreasonable (failing PR because of unchanged member).
@troosan troosan added the HTML label Feb 7, 2021
@troosan troosan changed the title Htmlchanges Add support for various missing features in HTML Writer Feb 7, 2021
@mussbach
Copy link
Contributor

There is quite a bunch of valuable stuff in that PR but as it is huge it is hard to review. Could you perhaps split this into multiple smaller PRs? It would be a pity if this PR would rot

@oleibman
Copy link
Contributor Author

It would be a lot of work to separate things. I would sort of like some assurance from the maintainer that the current state is a problem before I undertook it. That being said, I think I might be able to split it in 3 (PR is over a year old, so details aren't exactly fresh in my mind):

  • Work that just has to be done - bugs, design flaws - steps 1, 2, 6, 8, 9, and 13 (maybe).
  • Missing support for paragraph style - steps 10, 11, 12, and 13 (maybe - I think it's more important than the others).
  • New features and other missing support (steps 3, 4, 5, 7).

I realize you can't tell from this description how much would be left to review for each part. Neither can I ("not exactly fresh") without further study. Nevertheless, do you think what I describe above might be sufficient for your purposes?

@mussbach
Copy link
Contributor

I perfectly understand that this would be a lot of effort. I am not in the position to give any assurance so I fear we have to wait for some reaction

@troosan troosan added this to the v0.19.0 milestone Apr 15, 2021
@troosan
Copy link
Contributor

troosan commented Apr 15, 2021

That's indeed one big PR, with various fixes/improvements/features.

I'll try to review this for the next minor release

@oleibman
Copy link
Contributor Author

Thanks.

@Krato
Copy link

Krato commented Aug 23, 2021

Is this PR being to nbe implemented?

@Progi1984 Progi1984 removed this from the v1.0.0 milestone Nov 16, 2022
@PowerKiKi PowerKiKi changed the base branch from develop to master November 16, 2022 21:11
@Progi1984
Copy link
Member

@oleibman Thank your for your contribution. Could you rebase your PR ?

@oleibman
Copy link
Contributor Author

@Progi1984 I am not quite as conversant with git/github as I should be. The fact that there are now a number of merge conflicts, and that the main branch has changed from develop to master, make me a little uneasy doing anything to this PR. Would the following steps accomplish what you want instead?

  • rename my existing repository
  • make a fresh fork of PhpOffice/PhpWord
  • clone my new fork
  • make the same changes as in this PR
  • after local testing, push the new PR

If that looks like an okay plan, I can probably have something for you within a week. If it's not an okay plan, please tell me how to proceed instead.

@oleibman
Copy link
Contributor Author

oleibman commented Dec 1, 2022

I have completed a dry run where I applied my changes to the master version, and edited them according to the new standards (square brackets rather than array function for example - thank you @Progi1984 and @PowerKiKi, I can tell how painful a job that must have been just from my need to do it in a small number of members, but it was definitely time to do it). I am glad to report that I was able to get successful results for both the existing and the new unit tests. I want to do some more testing, but I can probably start working on a new PR in earnest in a day or two.

One question for now. I use the "check" script defined in composer.json for the project, and that failed because it invokes phpcs, which is not required by composer.json. I manually added it for my testing. Is it okay to proceed with that as a dev requirement, or should the check script be changed?

@oleibman oleibman closed this by deleting the head repository Dec 1, 2022
oleibman added a commit to oleibman/PHPWord that referenced this pull request Dec 1, 2022
This PR supersedes PHPOffice#1814, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.
@oleibman
Copy link
Contributor Author

oleibman commented Dec 1, 2022

@Progi1984 Rebased version is now available as PR #2343. I was, as I feared, unable to make a second fork, so I just deleted my fork, which caused this ticket to be closed, which I was planning to do anyhow.

oleibman added a commit to oleibman/PHPWord that referenced this pull request Sep 18, 2023
This PR supersedes PHPOffice#1814 and PHPOffice#2343, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.
Progi1984 pushed a commit to oleibman/PHPWord that referenced this pull request Nov 8, 2023
This PR supersedes PHPOffice#1814 and PHPOffice#2343, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

6 participants