Wincent wikitext nestingEdit
Overview
Block-level elements
BLOCKQUOTEPREOLULLIH1,H2,H3,H4,H5,H6P
In general, block elements may appear in the outermost scope, with some special considerations to note:
- Any block-level element may be nested inside
BLOCKQUOTE, including otherBLOCKQUOTEelements; the exception to this rule isLI, which may only be nesetd inside list elements (OLandLI) - Nested lists can be created by nesting
OLandLIinside anLI - All other nesting of block-level elements is disallowed
- The HTML specification states that heading elements (
H1,H2,H3,H4,H5,H6) should only appear in order in the document: that is,H2may only appear afterH1and so on; at least in the initial implementation I have no plans on enforcing this restriction
Inline elements
NO_WIKIEMSTRONGENTITYPRINTABLEDEFAULT
Inline elements always and only appear nested inside block-level elements.
Inline elements are intended for use within a single-line span, so a CRLF token automatically closes any open span-level tags (for parity with MediaWiki); the exception to this rule is the NO_WIKI span where everything including CRLF tokens loses its special significance. That is, even though NO_WIKI is a span-level element, it is not automatically closed upon seeing a CRLF token; this again is for parity with the established MediaWiki behaviour.
As noted on the Wincent wikitext page, nesting of inline elements inside one another is allowed provided that the same element is not nested inside itself (either directly or indirectly). Block-level elements may never be nested inside inline elements.
Entities
ENTITY tokens always have special meaning, even inside PRE blocks and NOWIKI spans. That is, a string like © inside a PRE or NOWIKI will be passed through literally into the HTML output as © rather than being converted to ©.
Details
Block-level elements
BLOCKQUOTE
- May be nested inside:
- Outermost (root) scope
BLOCKQUOTE(recursive nesting)
- Elements that can be nested inside:
BLOCKQUOTE(recursive nesting)PREOLULH1,H2,H3,H4,H5,H6P
Note: Although BLOCKQUOTE sections are introduced using the relatively common > character, the lexer screens out false positives by only emitting BLOCKQUOTE tokens when they appear in the first column of the input or are immediately preceded by other BLOCKQUOTE token(s).
PRE
- May be nested inside:
- Outermost (root) scope
BLOCKQUOTE
- Elements that can be nested inside:
- Any (but note that all elements lose their special meaning inside a
PRE)
- Any (but note that all elements lose their special meaning inside a
Note: Although PRE sections are introduced using the relatively common space character, the lexer screens out false positives by only emitting PRE tokens when they appear in the first column of the input or are immediately preceded by one or more BLOCKQUOTE tokens.
OL
- May be nested inside:
- Outermost (root) scope
BLOCKQUOTELI
- Elements that can be nested inside:
OL(indirect recursive nesting)UL
Note: Although OL sections are introduced using the relatively common # character, the lexer screens out false positives by only emitting OL tokens when they appear in the first column of the input or are immediately preceded by OL, UL or BLOCKQUOTE token(s).
UL
- May be nested inside:
- Outermost (root) scope
BLOCKQUOTELI
- Elements that can be nested inside:
OLUL(indirect recursive nesting)
Note: Although UL sections are introduced using the relatively common * character, the lexer screens out false positives by only emitting UL tokens when they appear in the first column of the input or are immediately preceded by OL, UL or BLOCKQUOTE token(s).
LI
- May be nested inside:
OLUL
- Elements that can be nested inside:
- Inline elements only
Note: LI is an imaginary token and is never actually emitted by the lexer.
H1, H2, H3, H4, H5, H6
- May be nested inside:
- Outermost (root) scope
BLOCKQUOTE(recursive nesting)
- Elements that can be nested inside:
- Inline elements only
Note: The lexer again avoids false positives by only emitting heading start tokens when they appear in the first column of the input, or are immediately preceded by a BLOCKQUOTE token. Similarly, heading end tokens are only emitted when they appear as the last non-whitespace symbol on a given line; this allows inputs such as the following to be correctly parsed as an <h2> heading containing the text Does foo == bar?:
== Does foo == bar? ==
P
- May be nested inside:
- Outermost (root) scope
BLOCKQUOTE(recursive nesting)
- Elements that can be nested inside:
- Inline elements only
Note: P is an imaginary token and is never actually emitted by the lexer.
Inline elements
NO_WIKI
- May be nested inside:
- Any block-level element
- Any inline element except for
NO_WIKIitself (directly or indirectly)
- Elements that can be nested inside:
- Any (but note that all elements lose their special meaning inside a
NO_WIKI)
- Any (but note that all elements lose their special meaning inside a
EM
- May be nested inside:
- Any block-level element
- Any inline element except for
EMitself (directly or indirectly)
- Elements that can be nested inside:
- Any inline element except for
EMitself (directly or indirectly)
- Any inline element except for
STRONG
- May be nested inside:
- Any block-level element
- Any inline element except for
STRONGitself (directly or indirectly)
- Elements that can be nested inside:
- Any inline element except for
STRONGitself (directly or indirectly)
- Any inline element except for
ENTITY
- May be nested inside:
- Any block-level element
- Any inline element
- Elements that can be nested inside:
- Not applicable (
ENTITYis an atomic element, not a span)
- Not applicable (
PRINTABLE
- May be nested inside:
- Any block-level element
- Any inline element
- Elements that can be nested inside:
- Not applicable (
PRINTABLEis an atomic element, not a span)
- Not applicable (
DEFAULT
- May be nested inside:
- Any block-level element
- Any inline element
- Elements that can be nested inside:
- Not applicable (
DEFAULTis an atomic element, not a span)
- Not applicable (