Merge "ExtractFormatter: Update for HtmlFormatter 4.0.0"

This commit is contained in:
jenkins-bot 2023-08-23 16:02:37 +00:00 committed by Gerrit Code Review
commit 84266ef050

View file

@ -44,7 +44,7 @@ class ExtractFormatter extends HtmlFormatter {
* Ignored * Ignored
* @return string Processed HTML * @return string Processed HTML
*/ */
public function getText( $element = null ) { public function getText( $element = null ): string {
$this->filterContent(); $this->filterContent();
$text = parent::getText(); $text = parent::getText();
if ( $this->plainText ) { if ( $this->plainText ) {
@ -63,7 +63,7 @@ class ExtractFormatter extends HtmlFormatter {
* @param string $html HTML string to process * @param string $html HTML string to process
* @return string Processed HTML * @return string Processed HTML
*/ */
public function onHtmlReady( $html ) { public function onHtmlReady( string $html ): string {
if ( $this->plainText ) { if ( $this->plainText ) {
$html = preg_replace( '/\s*(<h([1-6])\b)/i', $html = preg_replace( '/\s*(<h([1-6])\b)/i',
"\n\n" . self::SECTION_MARKER_START . '$2' . self::SECTION_MARKER_END . '$1', "\n\n" . self::SECTION_MARKER_START . '$2' . self::SECTION_MARKER_END . '$1',
@ -79,7 +79,7 @@ class ExtractFormatter extends HtmlFormatter {
* *
* @return array Array of removed DOMElements * @return array Array of removed DOMElements
*/ */
public function filterContent() { public function filterContent(): array {
$removed = parent::filterContent(); $removed = parent::filterContent();
$doc = $this->getDoc(); $doc = $this->getDoc();