Parcourir la source

Fix Python tokenizer to not generate empty Text tokens.

tags/v0.3
Ben Kurtovic il y a 11 ans
Parent
révision
b9324eb658
2 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. +2
    -1
      mwparserfromhell/parser/tokenizer.py
  2. +1
    -1
      tests/tokenizer/external_links.mwtest

+ 2
- 1
mwparserfromhell/parser/tokenizer.py Voir le fichier

@@ -424,7 +424,8 @@ class Tokenizer(object):
if brackets:
self._emit_text(before)
self._emit(tokens.ExternalLinkSeparator())
self._emit_text(after)
if after:
self._emit_text(after)
self._context ^= contexts.EXT_LINK_URI
self._context |= contexts.EXT_LINK_TITLE
self._head += 1


+ 1
- 1
tests/tokenizer/external_links.mwtest Voir le fichier

@@ -15,7 +15,7 @@ output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), Exte
name: brackets_space
label: basic external link in brackets, with a space after
input: "[http://example.com/ ]"
output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkSeparator(), Text(text=""), ExternalLinkClose()]
output: [ExternalLinkOpen(brackets=True), Text(text="http://example.com/"), ExternalLinkSeparator(), ExternalLinkClose()]

---



Chargement…
Annuler
Enregistrer