Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CSU
tweeki
Commits
ccde5866
Commit
ccde5866
authored
Apr 27, 2019
by
Tobias Haider
Browse files
Fix for headings with special chars
parent
e4ce2444
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/Hooks.php
View file @
ccde5866
...
...
@@ -59,16 +59,23 @@ class TweekiHooks {
$doc
=
new
DOMDocument
();
$html
=
mb_convert_encoding
(
$matches
[
0
],
'HTML-ENTITIES'
,
'UTF-8'
);
$doc
->
loadHTML
(
$html
);
$span
=
$doc
->
getElementsByTagName
(
'span'
)[
0
];
$heading
=
$doc
->
createElement
(
"span"
);
$heading
->
setAttribute
(
'class'
,
'mw-headline-content'
);
while
(
$span
->
firstChild
)
{
$heading
->
appendChild
(
$span
->
removeChild
(
$span
->
firstChild
)
);
$spans
=
$doc
->
getElementsByTagName
(
'span'
);
$mw_headline
=
''
;
foreach
(
$spans
as
$span
)
{
if
(
$span
->
getAttribute
(
'class'
)
==
'mw-headline'
)
{
$mw_headline
=
$span
;
}
}
/* move the contents of .mw-headline to a newly created .mw-headline-content */
$mw_headline_content
=
$doc
->
createElement
(
"span"
);
$mw_headline_content
->
setAttribute
(
'class'
,
'mw-headline-content'
);
while
(
$mw_headline
->
firstChild
)
{
$mw_headline_content
->
appendChild
(
$mw_headline
->
removeChild
(
$mw_headline
->
firstChild
)
);
}
$span
->
parentNode
->
insertBefore
(
$heading
,
$span
);
$span
->
parentNode
->
insertBefore
(
$span
,
$heading
);
return
(
$doc
->
saveHTML
(
$span
->
parentNode
)
);
/* put .mw-headline before .mw-headline-content */
$mw_headline
->
parentNode
->
insertBefore
(
$mw_headline_content
,
$mw_headline
);
$mw_headline
->
parentNode
->
insertBefore
(
$mw_headline
,
$mw_headline_content
);
return
(
$doc
->
saveHTML
(
$mw_headline
->
parentNode
)
);
},
$text
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment