Add wikipedia like table syntax (without style attributes)
Opened this issue · 0 comments
Piiit commented
static function pw_wiki_lexerconf(Lexer $lexer) {
$lexer->addWordPattern("newline", '(?<=\n)\n');
$lexer->addSectionPattern("wptable", '\n\{\|', '\|\}');
$lexer->addSectionPattern("wptableline", '\|-', '(?=\|\}|\|-)');
#$lexer->addSectionPattern("wptableheader", '\!\! *|\n\! *', '(?= *\!\!|\n)');
$lexer->addSectionPattern("wptableheader", '(\!\! *|\n\! *)', '(?= *\!\!|\n)'); //ENTRY must be bracketed... otherwise wptable finds its EXIT too early... wrong count!
$lexer->addSectionPattern("wptablecell", '(\|\| *|\n\|(?![\}-]) *)', '(?= *\|\||\n)');
$lexer->addLinePattern("wptabletitle", '\|\+ *');
$lexer->addWordPattern("wptableconfig", '([\w]+) *= *[\"\']?([^\"\']*)[\"\']? *\|* *');
$lexer->connectTo("wptableheader", "wptableline2");
$lexer->connectTo("wptablecell", "wptableline2");
// TODO: Aggregate categories and cleanup, Attention with Deflists and Modi, which must (not) be a part of their selfs...
$blocks = array("#DOCUMENT", "tablecell", "listitem", "multiline");
// $tables = array("tablecell", "tableheader", "wptableheader", "wptablecell");
$boxes = array("bordererror", "borderinfo", "borderwarning", "bordersuccess", "bordervalidation", "border");
// $format = array("bold", "underline", "italic", "monospace", "small", "big", "strike", "sub", "sup", "hi", "lo", "em");
// $align = array("align", "justify", "alignintable", "indent", "left", "right");
$lexer->setAllowedModes("newline", array_merge($blocks, $boxes, array("#DOCUMENT", "multiline")));
$lexer->setAllowedModes("wptable", array("#DOCUMENT", "multiline", "wptablecell"));
$lexer->setAllowedModes("wptableline", array("wptable"));
$lexer->setAllowedModes("wptabletitle", array("wptable"));
$lexer->setAllowedModes("wptableheader", array("wptableline", "wptable"));
$lexer->setAllowedModes("wptablecell", array("wptableline", "wptable"));
$lexer->setAllowedModes("wptableconfig", array("wptable", "wptableline", "wptableheader", "wptablecell", "wptabletitle"));
return $lexer;
}