Bladeren bron

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

tags/v0.3
Ben Kurtovic 11 jaren geleden
bovenliggende
commit
d1a7d25220
3 gewijzigde bestanden met toevoegingen van 8 en 6 verwijderingen
  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 Bestand weergeven

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


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


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


+ 5
- 5
mwparserfromhell/wikicode.py Bestand weergeven

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


from .compat import maxsize, py3k, str 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 .string_mixin import StringMixIn
from .utils import parse_anything from .utils import parse_anything


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


Wikicode._build_filter_methods( 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 Bestand weergeven

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


Laden…
Annuleren
Opslaan