浏览代码

Fix Python tokenizer to not generate empty Text tokens.

tags/v0.3
Ben Kurtovic 11 年前
父节点
当前提交
b9324eb658
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. +2
    -1
      mwparserfromhell/parser/tokenizer.py
  2. +1
    -1
      tests/tokenizer/external_links.mwtest

+ 2
- 1
mwparserfromhell/parser/tokenizer.py 查看文件

@@ -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 查看文件

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

---



正在加载...
取消
保存