瀏覽代碼

Set right context for ExternalLink.url; Wikicode.filter_external_links()

tags/v0.3
Ben Kurtovic 11 年之前
父節點
當前提交
d1a7d25220
共有 3 個檔案被更改,包括 8 行新增6 行删除
  1. +2
    -1
      mwparserfromhell/nodes/external_link.py
  2. +5
    -5
      mwparserfromhell/wikicode.py
  3. +1
    -0
      tests/test_wikicode.py

+ 2
- 1
mwparserfromhell/nodes/external_link.py 查看文件

@@ -85,7 +85,8 @@ class ExternalLink(Node):

@url.setter
def url(self, value):
self._url = parse_anything(value)
from ..parser import contexts
self._url = parse_anything(value, contexts.EXT_LINK_URI)

@title.setter
def title(self, value):


+ 5
- 5
mwparserfromhell/wikicode.py 查看文件

@@ -24,8 +24,8 @@ from __future__ import unicode_literals
import re

from .compat import maxsize, py3k, str
from .nodes import (Argument, Comment, Heading, HTMLEntity, Node, Tag,
Template, Text, Wikilink)
from .nodes import (Argument, Comment, ExternalLink, Heading, HTMLEntity,
Node, Tag, Template, Text, Wikilink)
from .string_mixin import StringMixIn
from .utils import parse_anything

@@ -509,6 +509,6 @@ class Wikicode(StringMixIn):
return "\n".join(self._get_tree(self, [], marker, 0))

Wikicode._build_filter_methods(
arguments=Argument, comments=Comment, headings=Heading,
html_entities=HTMLEntity, tags=Tag, templates=Template, text=Text,
wikilinks=Wikilink)
arguments=Argument, comments=Comment, external_links=ExternalLink,
headings=Heading, html_entities=HTMLEntity, tags=Tag, templates=Template,
text=Text, wikilinks=Wikilink)

+ 1
- 0
tests/test_wikicode.py 查看文件

@@ -276,6 +276,7 @@ class TestWikicode(TreeEqualityTestCase):
self.assertEqual(["{{{e}}}"], get_filter("arguments"))
self.assertIs(code.get(4), get_filter("arguments")[0])
self.assertEqual([], get_filter("comments"))
self.assertEqual([], get_filter("external_links"))
self.assertEqual([], get_filter("headings"))
self.assertEqual([], get_filter("html_entities"))
self.assertEqual([], get_filter("tags"))


Loading…
取消
儲存