Skip to content

Commit

Permalink
Ensure style inheritance is used in exported HTML documents (for PHPO…
Browse files Browse the repository at this point in the history
  • Loading branch information
0b10011 committed Aug 30, 2019
1 parent c629afb commit 8dad5c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/PhpWord/Writer/HTML/Part/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ private function writeStyles()

// Default styles
$defaultStyles = array(
'*' => array(
// 'html' is used instead of '*' to ensure nested elements inherit from their parents.
// `h1 > span` should have the same font size as the `h1` parent.
'html' => array(
'font-family' => Settings::getDefaultFontName(),
'font-size' => Settings::getDefaultFontSize()->toInt('pt') . 'pt',
),
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpWord/Shared/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testRoundTripHeadings()
<meta charset="UTF-8" />
<title>PHPWord</title>
<style title="PHPWord Base Styles">
* {font-family: Arial; font-size: 10pt;}
html {font-family: Arial; font-size: 10pt;}
a.NoteRef {text-decoration: none;}
hr {height: 1px; padding: 0; margin: 1em 0; border: 0; border-top: 1px solid #CCC;}
table {border: 1px solid black; border-spacing: 0px; width : 100%;}
Expand Down

0 comments on commit 8dad5c7

Please sign in to comment.