mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-09 21:25:39 +00:00
wikiheaders.pl: Don't treat chars in code
blocks as markdown.
Otherwise a formula like `x = y * 2;` would treat that '*' as the start of an italicized section when converting to MediaWiki format, and match any other '*' in the content as the end marker.
This commit is contained in:
parent
2f93fbbb75
commit
7def81cf42
|
@ -136,14 +136,21 @@ sub wikify_chunk {
|
||||||
#print("\n\nWIKIFY CHUNK:\n\n$str\n\n\n");
|
#print("\n\nWIKIFY CHUNK:\n\n$str\n\n\n");
|
||||||
|
|
||||||
if ($wikitype eq 'mediawiki') {
|
if ($wikitype eq 'mediawiki') {
|
||||||
|
# convert `code` things first, so they aren't mistaken for other markdown items.
|
||||||
|
my $codedstr = '';
|
||||||
|
while ($str =~ s/\A(.*?)\`(.*?)\`//ms) {
|
||||||
|
my $codeblock = $2;
|
||||||
|
$codedstr .= wikify_chunk($wikitype, $1, undef, undef);
|
||||||
|
# Convert obvious SDL things to wikilinks, even inside `code` blocks.
|
||||||
|
$codeblock =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
|
||||||
|
$codedstr .= "<code>$codeblock</code>";
|
||||||
|
}
|
||||||
|
|
||||||
# Convert obvious SDL things to wikilinks.
|
# Convert obvious SDL things to wikilinks.
|
||||||
$str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
|
$str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
|
||||||
|
|
||||||
# Make some Markdown things into MediaWiki...
|
# Make some Markdown things into MediaWiki...
|
||||||
|
|
||||||
# <code></code> is also popular. :/
|
|
||||||
$str =~ s/\`(.*?)\`/<code>$1<\/code>/gms;
|
|
||||||
|
|
||||||
# bold+italic
|
# bold+italic
|
||||||
$str =~ s/\*\*\*(.*?)\*\*\*/'''''$1'''''/gms;
|
$str =~ s/\*\*\*(.*?)\*\*\*/'''''$1'''''/gms;
|
||||||
|
|
||||||
|
@ -156,6 +163,8 @@ sub wikify_chunk {
|
||||||
# bullets
|
# bullets
|
||||||
$str =~ s/^\- /* /gm;
|
$str =~ s/^\- /* /gm;
|
||||||
|
|
||||||
|
$str = $codedstr . $str;
|
||||||
|
|
||||||
if (defined $code) {
|
if (defined $code) {
|
||||||
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
|
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue