The parser has to deal with different contexts.
Main contexts
Different document types support different contexts. With default preference values, a wiki page can contain Wiki syntax and HTML would be displayed literally. But if so configured, pages can contain HTML. And if so configured, pages can be edited with a WYSIWYG editor.
Database
Wiki pages are stored in tiki_pages. There are 2 relevant columns in tiki_pages, is_html and wysiwyg. WYSIWYG pages have tiki_pages.wysiwyg=y.
With default configuration, pages are by default created with tiki_pages.is_html=0 and tiki_pages.wysiwyg=n.
“Allow HTML” (non-WYSIWYG HTML) pages have is_html=1 and tiki_pages.wysiwyg=n.
“WYSIWYG HTML” pages have tiki_pages.is_html=1 and tiki_pages.wysiwyg=y.
“WYSIWYG wiki” pages have tiki_pages.is_html=0 and tiki_pages.wysiwyg=y.
Tracking of WYSIWYG or HTML support is not consistent in all object types. For example, blog posts only track whether they use WYSIWYG or not. If WYSIWYG is enabled, HTML is supported, but if tiki_blog_posts.wysiwyg is "n", HTML is displayed literally.
Preferences and settings
When the feature_wiki_allowhtml preference ("Allow HTML") is enabled, each wiki page gets a "Allow HTML" setting making it possible to allow HTML.
The wysiwyg_htmltowiki preference affects all new pages, but none of the pages created before it was enabled. To switch an old page, it must be converted to non-WYSIWYG, saved, then converted back to WYSIWYG.
The wysiwyg_wiki_parsed preference was added to disable parsing in a non-WYSIWYG page if "Allow HTML" is enabled, but also affects WYSIWYG pages as of 2018-02-05. Thread "The Epic Story of wysiwyg_wiki_[semi_]parsed - Is the End Coming?" has more information on that preference.
The effect of the "Allow HTML" setting is the same as putting the whole content of a page in a call to the HTML plugin.
Plugins
Besides the INCLUDE plugin, 2 plugins enable to change the context: HTML, which supports HTML and Tiki syntax or just HTML, and WYSIWYG, which supports either HTML or Tiki syntax.
Map of contexts
This list attempts to picture all possible contexts and sub-contexts where parsable texts may occur, but this recurses with no limit. Arrows in a yellow disk indicate subcontexts to which an infinity of subcontexts could be added.
Incorrect behavior is in red. Behavior which could be considered wrong looking at part of the tree but right looking at another part is in orange.
- WYSIWYG page
- wysiwyg_htmltowiki enabled
- Regular: HTML is escaped. Tiki markup is interpreted.
- In HTML plugin. Problematic according to https://dev.tiki.org/item4741
- Wiki syntax parameter enabled: HTML interpreted, Tiki markup not parsed.
- Wiki syntax parameter disabled: HTML interpreted, Tiki markup only parsed if wysiwyg_wiki_parsed is enabled.
- In WYSIWYG plugin – must be rare
- use_html enabled: HTML is interpreted but converted to Tiki markup on edition. Tiki markup is interpreted.
- use_html disabled: HTML is interpreted, Tiki markup is interpreted.
- wysiwyg_htmltowiki disabled
- wysiwyg_wiki_parsed enabled : HTML is interpreted. Tiki syntax is interpreted. As of 2018-02-06, affected by "What you see in WYSIWYG editor is NOT NECESSARILY what you get" (see ticket #6523)
- wysiwyg_wiki_parsed disabled : HTML is interpreted. Tiki syntax not interpreted. As of 2018-02-06, affected by No plugins and WYSIWYG help is wrong/broken (see ticket #6527)
- wysiwyg_htmltowiki enabled
- Non-WYSIWYG page
- HTML not allowed
- Regular content (outside WYSIWYG or HTML): HTML is escaped. Tiki syntax is parsed.
- Content in HTML plugin
- Wiki syntax parameter enabled
- Regular content (outside WYSIWYG or HTML): HTML is interpreted. Tiki syntax is parsed. Broken prior to 19 (65157)
- Content in WYSIWYG plugin
- use_html enabled : HTML is interpreted. Tiki syntax is interpreted.
- use_html disabled : HTML is interpreted. Tiki syntax is interpreted.
- Wiki syntax parameter disabled: HTML is interpreted. Tiki syntax is not interpreted.
- Wiki syntax parameter enabled
- Content in WYSIWYG plugin
- use_html enabled : HTML is interpreted. Tiki markup is interpreted, so "What you see in WYSIWYG editor is NOT NECESSARILY what you get" (see ticket #6523), but plugins are still invisible as of 2018-02-06.
- use_html disabled
- Regular content : HTML is interpreted. Tiki markup is interpreted, plugins are invisible as of 2018-02-06 (see ticket #6551).
- Content in HTML plugin?
- HTML allowed. Simply enabling HTML affects newlines.
- wysiwyg_wiki_parsed enabled: HTML is interpreted. Tiki markup is interpreted
- wysiwyg_wiki_parsed disabled: HTML is interpreted. Tiki markup is not interpreted.
- HTML not allowed
Tests
- Parser_wiki_test - Test wiki page for the default context
- Parser test - HTML page.txt (just a file containing the source, since HTML pages cannot be created on dev.tiki.org)