Bmansurov has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/362298 )

Change subject: Keep math images while removing formulas from HTML output
......................................................................

Keep math images while removing formulas from HTML output

`.mwe-math-fallback-image` and `.mwe-math-fallback-image-inline` are not being
stripped from the HTML output. Rather the math formulas with the
`.mwe-math-mathml-inline` class are being removed.

In text mode formulas are kept, while all images are removed.

Depends-on: Id1934e4fb9aaa16e6f0de2db278817b7149c2923
Change-Id: I916832afbf52f4a566af817be7e089a726b5ce94
Bug: T159065
---
M extension.json
M includes/ExtractFormatter.php
2 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts 
refs/changes/98/362298/1

diff --git a/extension.json b/extension.json
index 259bbc4..d73a992 100644
--- a/extension.json
+++ b/extension.json
@@ -49,6 +49,15 @@
                        ".noexcerpt",
                        ".sortkey"
                ],
+               "ExtractsRemoveClassesFromHTML": [
+                       ".mwe-math-mathml-inline"
+               ],
+               "ExtractsMediaClassesToKeep": {
+                       "img": [
+                               "mwe-math-fallback-image",
+                               "mwe-math-fallback-image-inline"
+                       ]
+               },
                "ExtractsExtendOpenSearchXml": false
        },
        "manifest_version": 1
diff --git a/includes/ExtractFormatter.php b/includes/ExtractFormatter.php
index 4dd7e92..df8b396 100644
--- a/includes/ExtractFormatter.php
+++ b/includes/ExtractFormatter.php
@@ -41,11 +41,13 @@
                $this->plainText = $plainText;
 
                $this->setRemoveMedia( true );
+               $this->keepMediaClass( $config->get( 
'ExtractsMediaClassesToKeep' ) );
                $this->remove( $config->get( 'ExtractsRemoveClasses' ) );
 
                if ( $plainText ) {
                        $this->flattenAllTags();
                } else {
+                       $this->remove ( $config->get( 
'ExtractsRemoveClassesFromHTML' ) );
                        $this->flatten( [ 'a' ] );
                }
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/362298
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I916832afbf52f4a566af817be7e089a726b5ce94
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TextExtracts
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to