Quellcode durchsuchen

Compat for the parser itself.

tags/v0.1
Ben Kurtovic vor 12 Jahren
Ursprung
Commit
391a5bd373
3 geänderte Dateien mit 9 neuen und 14 gelöschten Zeilen
  1. +1
    -1
      mwparserfromhell/parser/builder.py
  2. +2
    -2
      mwparserfromhell/parser/tokenizer.py
  3. +6
    -11
      mwparserfromhell/parser/tokens.py

+ 1
- 1
mwparserfromhell/parser/builder.py Datei anzeigen

@@ -23,11 +23,11 @@
from __future__ import unicode_literals

from . import tokens
from ..compat import str
from ..nodes import Heading, HTMLEntity, Tag, Template, Text
from ..nodes.extras import Attribute, Parameter
from ..smart_list import SmartList
from ..wikicode import Wikicode
from ..compat import str, bytes

__all__ = ["Builder"]



+ 2
- 2
mwparserfromhell/parser/tokenizer.py Datei anzeigen

@@ -27,7 +27,7 @@ import string

from . import contexts
from . import tokens
from ..compat import htmlentitydefs
from ..compat import htmlentities

__all__ = ["Tokenizer"]

@@ -230,7 +230,7 @@ class Tokenizer(object):
if test < 1 or test > 0x10FFFF:
self._fail_route()
else:
if this not in htmlentitydefs.entitydefs:
if this not in htmlentities.entitydefs:
self._fail_route()

self._write(tokens.Text(text=this))


+ 6
- 11
mwparserfromhell/parser/tokens.py Datei anzeigen

@@ -21,7 +21,8 @@
# SOFTWARE.

from __future__ import unicode_literals
from ..compat import str, bytes, v

from ..compat import basestring, str

__all__ = ["Token"]

@@ -31,7 +32,7 @@ class Token(object):

def __repr__(self):
args = []
for key, value in self._kwargs.iteritems():
for key, value in self._kwargs.items():
if isinstance(value, basestring) and len(value) > 100:
args.append(key + "=" + repr(value[:97] + "..."))
else:
@@ -52,15 +53,9 @@ class Token(object):
def __delattr__(self, key):
del self._kwargs[key]

if v >= 3:
def make(name):
__all__.append(name)
return type(name, (Token,), {})
else:
def make(name):
name = name.encode("utf-8")
__all__.append(name)
return type(name, (Token,), {})
def make(name):
__all__.append(name)
return type(name, (Token,), {})

Text = make("Text")



Laden…
Abbrechen
Speichern