Compare commits
2 commits
cdb35a545d
...
4ca967ff4d
Author | SHA1 | Date | |
---|---|---|---|
4ca967ff4d | |||
1499b9aa3c |
14
README.md
Normal file
14
README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# fanwikis/Description2
|
||||
|
||||
This is a fork of the MediaWiki Description2 extension maintained by the fanwikis.org Team with tweaks and improvements for use on fanwikis.org's MediaWiki installation.
|
||||
|
||||
## Changes
|
||||
|
||||
### Removing <style> tags
|
||||
|
||||
When using the TemplateStyles extension at the top of an article, the Description may end up being just CSS. This is not what we want, so we remove the <style> tags from the description.
|
||||
|
||||
```diff
|
||||
- $pattern = '%<table\b[^>]*+>(?:(?R)|[^<]*+(?:(?!</?table\b)<[^<]*+)*+)*+</table>%i';
|
||||
+ $pattern = '%<(table|style)\b[^>]*+>(?:(?R)|[^<]*+(?:(?!</?(table|style)\b)<[^<]*+)*+)*+</(table|style)>%i';
|
||||
```
|
|
@ -8,7 +8,7 @@ class SimpleDescriptionProvider implements DescriptionProvider {
|
|||
* Extracts description from the HTML representation of a page.
|
||||
*
|
||||
* The algorithm:
|
||||
* 1. Removes all <table> elements and their contents.
|
||||
* 1. Removes all <table> and <style> elements and their contents.
|
||||
* 2. Selects all <p> elements.
|
||||
* 3. Iterates over those paragraphs, strips out all HTML tags and trims white-space around.
|
||||
* 4. Then the first non-empty paragraph is picked as the result.
|
||||
|
@ -17,7 +17,7 @@ class SimpleDescriptionProvider implements DescriptionProvider {
|
|||
* @return string
|
||||
*/
|
||||
public function derive( string $text ): ?string {
|
||||
$pattern = '%<table\b[^>]*+>(?:(?R)|[^<]*+(?:(?!</?table\b)<[^<]*+)*+)*+</table>%i';
|
||||
$pattern = '%<(table|style)\b[^>]*+>(?:(?R)|[^<]*+(?:(?!</?(table|style)\b)<[^<]*+)*+)*+</(table|style)>%i';
|
||||
$myText = preg_replace( $pattern, '', $text );
|
||||
|
||||
$paragraphs = [];
|
||||
|
|
Loading…
Reference in a new issue