Procházet zdrojové kódy

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 před 10 roky
rodič
revize
0bba69d5dc
2 změnil soubory, kde provedl 15 přidání a 1 odebrání
  1. +1
    -1
      mwparserfromhell/parser/tokenizer.py
  2. +14
    -0
      tests/tokenizer/tables.mwtest

+ 1
- 1
mwparserfromhell/parser/tokenizer.py Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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|}"


Načítá se…
Zrušit
Uložit