Browse Source

rewrite Caveats

>not supported, since they cannot be represented in the node tree.
It's not that they cannot be represented, it's that they would have to be evaluated.
tags/v0.5
Larivact 6 years ago
committed by GitHub
parent
commit
2d89f611be
1 changed files with 10 additions and 9 deletions
  1. +10
    -9
      README.rst

+ 10
- 9
README.rst View File

@@ -115,12 +115,18 @@ Likewise, use ``unicode(code)`` in Python 2.

Caveats
-------
mwparserfromhell generates an abstract syntax tree instead of HTML.
While the MediaWiki parser generates HTML, mwparserfromhell acts as an interface to
the source code. mwparserfromhell therefore is unaware of template definitions since
if it would substitute templates with their output you could no longer change the templates.
This has several implications:

* Crossed constructs like ``{{echo|''Hello}}, world!''`` are not supported,
since they cannot be represented in the node tree. We compromise by treating
the first node (i.e. the template) as plain text, parsing only the italics.
* Start and end tags generated by templates aren't recognized e.g. ``<b>foobar{{bold-end}}``.

* Templates adjacent to external links e.g. ``http://example.com{{foo}}`` are
considered part of the link.

* Crossed constructs like ``{{echo|''Hello}}, world!''`` are not supported.
We compromise by treating the first node as plain text.

The current workaround for cases where you are not interested in text
formatting is to pass ``skip_style_tags=True`` to ``mwparserfromhell.parse()``.
@@ -129,11 +135,6 @@ This has several implications:
A future version of mwparserfromhell will include multiple parsing modes to get
around this restriction.

* Templates adjacent to external links e.g. ``http://example.com{{foo}}`` are
considered part of the link, since mwparserfromhell does not know the
definition of templates and even if it did the template could only be
partially part of the link which also couldn't be represented in the AST.

Integration
-----------



Loading…
Cancel
Save