User:Lahwaacz/Notes
Indenting multiline code blocks
MediaWiki does not support multiparagraph list items (and other complex scenarios):
- https://stackoverflow.com/questions/4994174/code-block-in-numbered-list-wiki-syntax
- https://bugzilla.wikimedia.org/show_bug.cgi?id=1115
- https://bugzilla.wikimedia.org/show_bug.cgi?id=1584
Basically every newline character breaks the list. As a result, multiline code blocks using Template:bc cannot be used inside lists and cannot be indented using colons, unless the content is escaped using <nowiki> tags. Template:hc breaks completely, because the template itself contains a line break -- this is another hack, need to find reference for the The line break is needed, otherwise the wiki will generate extraneous paragraphs inside the 2nd pre block
comment.
Another possible workaround is to use HTML-encoded characters, see [1].
Perhaps #tag:pre parser function could solve this? See [2].
API: resolving redirects
Goal: obtain a mapping of all redirect titles to their targets
Method 1: using the redirects
parameter: mw:API:Query#Resolving_redirects
Works [3], but additional query is required to obtain list of redirect pages: [4].
Also note that the limit for pageids=
parameter is lower than for the generator. Passing more page IDs at once will result only in warning and the limit number of pages will be returned (in random order).
Method 2: using generator=allpages
along with prop=redirects
. Make sure that limits are properly set (see the first method).
Unfortunately post-processing is required to transform the data to more sensible form, but all data is returned in one query per target namespace: [5].
rdnamespace
to any value results in internal database query error: [6].
{ "error": { "code": "internal_api_error_DBQueryError", "info": "[15e71f58] Database query error" } }
Removing rdnamespace
fixes it [7], Wikipedia is completely fine: [8].
Method 3: using generator=allredirects
(implemented at the same time as method 3, see T59057)
The idea is to use garunique
parameter to generate target redirects pages instead of source redirects and prop=redirects
to obtain further info on pages redirecting to these titles. This is less expensive than generator=allpages
, but unfortunately broken with respect to interwiki redirects: T105234.
Documentation: mw:API:Allredirects
References:
- [10] - unfortunately
redirects
parameter cannot be combined withgenerator=allpages
- wikipedia:User:Richard0612/redirect.py
blame mode
- http://www.mediawiki.org/wiki/Feature_map#3._Page-level_change_tracking
- https://bugzilla.wikimedia.org/show_bug.cgi?id=639
- http://hewgill.com/journal/entries/461-wikipedia-blame
Parser
- https://www.mediawiki.org/wiki/Markup_spec
- http://www.mediawiki.org/wiki/One-pass_parser
- http://meatballwiki.org/wiki/ConsumeParseRenderVsMatchTransform
- http://www.mediawiki.org/wiki/Alternative_parsers
- http://www.mediawiki.org/wiki/Parsoid
- https://blog.wikimedia.org/2013/03/04/parsoid-how-wikipedia-catches-up-with-the-web/
- https://meta.wikimedia.org/wiki/Migration_to_the_new_preprocessor
LanguageConverter
- https://www.mediawiki.org/wiki/Writing_systems
- https://www.mediawiki.org/wiki/Writing_systems/Syntax
- https://phabricator.wikimedia.org/T21044
- https://phabricator.wikimedia.org/T43716
Gotchas
separate paragraphs
in template arguments.Only ASCII whitespace is stripped around template parameters
- foo
- bar
vs.
- bar
Double brackets escape template-breaking characters
This actually works:
{{Warning|Linux kernel 5.5.6 causes a hang on udev, also reported in Fedora [[https://bugzilla.redhat.com/show_bug.cgi?id=1772498#c205 here]]. 5.5.7 fixes this.}}
Templates
- https://meta.wikimedia.org/wiki/Help:Template
- https://meta.wikimedia.org/wiki/Help:Recursive_conversion_of_wikitext
- https://phabricator.wikimedia.org/T13375
- https://meta.wikimedia.org/wiki/Help:Newlines_and_spaces#Trimming_on_expansion
Fancy section headings
This is why styling section headings is forbidden by Help:Style:
Section with wikicode
Link: #Section with wikicode
Link: #Section with wikicode (invalid)
Section with tag
Link: #Section with tag
Link: [[#Section with tag]] (invalid)
Section with <it>invalid tag</it>
Link: #Section with <it>invalid tag</it>
Section with templateAUR
Link: #Section with templateAUR (depending on the template, the anchor could be much worse)
Section with wikilink
Link: #Section with wikilink
Section with <nowiki>
Link: #Section with .3Cnowiki.3E
Link: [[#Section with <nowiki>]]
Special symbols
Section with HTML entities Σ, Σ, and Σ
Link: #Section_with_HTML_entities_.CE.A3.2C_.CE.A3.2C_and_.CE.A3 (dot-encoded)
Link: #Section with HTML entities Σ, Σ, and Σ (percent-encoded)
Link: #Section with HTML entities Σ, Σ, and Σ (HTML entities)
Link: #Section with HTML entities Σ, Σ, and Σ (unicode symbols)
Section with [brackets]
Link: #Section with .5Bbrackets.5D (dot-encoded)
Link: #Section with [brackets] (percent-encoded)
Section with | pipe
Link: #Section with .7C pipe (dot-encoded)
Link: #Section with | pipe (percent-encoded)
Section anchors
For some reason, even unique section anchors may get the number suffix: