瀏覽代碼

Added tests/support for header cells

Support for header cells was mostly in already, just needed minor
changes. Added two tests as well.
tags/v0.4
David Winegar 10 年之前
父節點
當前提交
0bba69d5dc
共有 2 個檔案被更改,包括 15 行新增1 行删除
  1. +1
    -1
      mwparserfromhell/parser/tokenizer.py
  2. +14
    -0
      tests/tokenizer/tables.mwtest

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

@@ -63,7 +63,7 @@ class Tokenizer(object):
START = object()
END = object()
MARKERS = ["{", "}", "[", "]", "<", ">", "|", "=", "&", "'", "#", "*", ";",
":", "/", "-", "\n", START, END]
":", "/", "-", "!", "\n", START, END]
MAX_DEPTH = 40
MAX_CYCLES = 100000
regex = re.compile(r"([{}\[\]<>|=&'#*;:/\\\"\-!\n])", flags=re.IGNORECASE)


+ 14
- 0
tests/tokenizer/tables.mwtest 查看文件

@@ -61,6 +61,20 @@ output: [TagOpenOpen(wiki_markup="{|"), Text(text="table"), TagCloseOpen(), Text

---

name: table_header_simple
label: Simple header cell.
input: "{|\n ! foo \n|}"
output: [TagOpenOpen(wiki_markup="{|"), Text(text="table"), TagCloseOpen(), Text(text="\n "), TagOpenOpen(wiki_markup="!"), Text(text="th"), TagCloseSelfclose(), Text(text=" foo \n"), TagOpenClose(), Text(text="table"), TagCloseClose()]

---

name: table_header_inline
label: Multiple inline header cells.
input: "{|\n ! foo || bar !! test \n|}"
output: [TagOpenOpen(wiki_markup="{|"), Text(text="table"), TagCloseOpen(), Text(text="\n "), TagOpenOpen(wiki_markup="!"), Text(text="th"), TagCloseSelfclose(), Text(text=" foo "), TagOpenOpen(wiki_markup="||"), Text(text="th"), TagCloseSelfclose(), Text(text=" bar "),TagOpenOpen(wiki_markup="!!"), Text(text="th"), TagCloseSelfclose(), Text(text=" test \n"), TagOpenClose(), Text(text="table"), TagCloseClose()]

---

name: nowiki_inside_table
label: Nowiki handles pipe characters in tables.
input: "{|\n | foo <nowiki>| |- {| |} || ! !!</nowiki> bar \n|}"


Loading…
取消
儲存