Kaynağa Gözat

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

tags/v0.3
Ben Kurtovic 11 yıl önce
ebeveyn
işleme
d1a7d25220
3 değiştirilmiş dosya ile 8 ekleme ve 6 silme
  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 Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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"))


Yükleniyor…
İptal
Kaydet