Pārlūkot izejas kodu

Fix Python tokenizer to not generate empty Text tokens.

tags/v0.3
Ben Kurtovic pirms 11 gadiem
vecāks
revīzija
b9324eb658
2 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. +2
    -1
      mwparserfromhell/parser/tokenizer.py
  2. +1
    -1
      tests/tokenizer/external_links.mwtest

+ 2
- 1
mwparserfromhell/parser/tokenizer.py Parādīt failu

@@ -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 Parādīt failu

@@ -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()]

---



Notiek ielāde…
Atcelt
Saglabāt