瀏覽代碼

A unicode fix and a quick stub for strip_code()

tags/v0.1
Ben Kurtovic 12 年之前
父節點
當前提交
83c5e3c9ec
共有 2 個文件被更改,包括 5 次插入4 次删除
  1. +1
    -1
      mwparserfromhell/string_mixin.py
  2. +4
    -3
      mwparserfromhell/wikicode.py

+ 1
- 1
mwparserfromhell/string_mixin.py 查看文件

@@ -27,7 +27,7 @@ class StringMixIn(object):
return unicode(self).encode("utf8")

def __repr__(self):
return repr(unicode(self).encode("utf8"))
return repr(unicode(self))

def __lt__(self, other):
if isinstance(other, unicodeingMixin):


+ 4
- 3
mwparserfromhell/wikicode.py 查看文件

@@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import htmlentitydefs
import re

import mwparserfromhell
@@ -182,9 +183,9 @@ class Wikicode(StringMixIn):
def filter_text(self, recursive=False, matches=None, flags=FLAGS):
return list(self.ifilter_text(recursive, matches, flags))

def normalize(self):
## Create a deep copy of self ##
return normalized
def strip_code(self, normalize=True):
# Magic with htmlentitydefs if normalize
return normalized(u" ".join(self.ifilter_text()))

def show_tree(self):
marker = object() # Random object we can find with certainty in a list


Loading…
取消
儲存