26 private static $formattingAttributes = [
38 private $formattingOptions;
43 private $stripPeriods =
false;
55 $this->formattingOptions =
new ArrayList();
58 foreach ($node->attributes() as $attribute) {
61 $name = (string) $attribute->getName();
62 $value = (string) $attribute;
64 if (in_array($name, self::$formattingAttributes)) {
65 $this->formattingOptions->add($name, $value);
72 protected function format($text)
78 if (!empty($this->formattingOptions)) {
80 foreach ($this->formattingOptions as $option => $optionValue) {
81 if ($optionValue ===
"italic") {
82 $text =
"<i>$text</i>";
83 } elseif ($optionValue ===
"bold") {
84 $text =
"<b>$text</b>";
85 } elseif ($optionValue ===
"normal") {
87 } elseif ($option ===
"vertical-align") {
88 if ($optionValue ===
"sub") {
89 $text =
"<sub>$text</sub>";
90 } elseif ($optionValue ===
"sup") {
91 $text =
"<sup>$text</sup>";
93 } elseif ($option ===
"text-decoration" && $optionValue ===
"none") {
96 $format .=
"$option: $optionValue;";
99 if (!empty($format)) {
100 $text =
'<span style="' . $format .
'">' . $text .
'</span>';