A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
2.1 KiB

  1. Limitations
  2. ===========
  3. While the MediaWiki parser generates HTML and has access to the contents of
  4. templates, among other things, mwparserfromhell acts as a direct interface to
  5. the source code only. This has several implications:
  6. * Syntax elements produced by a template transclusion cannot be detected. For
  7. example, imagine a hypothetical page ``"Template:End-bold"`` that contained
  8. the text ``</b>``. While MediaWiki would correctly understand that
  9. ``<b>foobar{{end-bold}}`` translates to ``<b>foobar</b>``, mwparserfromhell
  10. has no way of examining the contents of ``{{end-bold}}``. Instead, it would
  11. treat the bold tag as unfinished, possibly extending further down the page.
  12. * Templates adjacent to external links, as in ``http://example.com{{foo}}``,
  13. are considered part of the link. In reality, this would depend on the
  14. contents of the template.
  15. * When different syntax elements cross over each other, as in
  16. ``{{echo|''Hello}}, world!''``, the parser gets confused because this cannot
  17. be represented by an ordinary syntax tree. Instead, the parser will treat the
  18. first syntax construct as plain text. In this case, only the italic tag would
  19. be properly parsed.
  20. **Workaround:** Since this commonly occurs with text formatting and text
  21. formatting is often not of interest to users, you may pass
  22. *skip_style_tags=True* to ``mwparserfromhell.parse()``. This treats ``''``
  23. and ``'''`` as plain text.
  24. A future version of mwparserfromhell may include multiple parsing modes to
  25. get around this restriction more sensibly.
  26. Additionally, the parser lacks awareness of certain wiki-specific settings:
  27. * `word-ending links`_ are not supported, since the linktrail rules are
  28. language-specific.
  29. * Localized namespace names aren't recognized, so file links (such as
  30. ``[[File:...]]``) are treated as regular wikilinks.
  31. * Anything that looks like an XML tag is treated as a tag, even if it is not a
  32. recognized tag name, since the list of valid tags depends on loaded MediaWiki
  33. extensions.
  34. .. _word-ending links: https://www.mediawiki.org/wiki/Help:Links#linktrail