User:PerfektesChaos/js/WikiSyntaxTextMod/flow/tag

WikiSyntaxTextMod → Syntax polishing → Step 2

The second step in the syntax polishing exercise standardizes tags like  (also comments) and detects errors.

Scope
The common and unique appearance of tags is accomplished. Human authors shall not be confused by various formatting styles. Bots and scripts may identify structures in a reliable and simple manner.

Only well known elements will be processed:

Comments are considered here, too.

All unknown tags will be ignored.

Formatting
The following format is expected after polishing:
 * A known tag opened by  is to be closed by   and no other   or   is permitted inside.
 * After and before the limiting  there is no whitespace.
 * All known tags as enumerated above consist of lowercase letters only.
 * If a backslash  is detected just after   or before   a manual mistake is assumed and this one is turned into a regular slash.
 * An end tag is written in compact notation:.
 * An unary tag (like ) is written with exactly one space between name (or attribute) and slash.
 * Elements which are permitted in HTML unary only (,  and  ) are enforced to be a unary tag whereever what kind of slash might be present.
 * Empty elements (like  and  ) will be turned into one unary tag.
 * If there is only whitespace (spaces or linebreaks) between the tags they are regarded as empty, too. There is an optical effect of \n  but not meaningful except for the Whitespace language. However,   keeps any content unchanged. In other cases an empty tag pair is to be filled with some content.
 * For  an exception is made.
 * All attribute names are turned into lowercase letters.
 * Every attribute is permitted only one time, multiple occurrence causes an error message.
 * Attribute assignments are written as  in compact notation:
 * Whitespace around the equal sign will be removed.
 * The value is encosed in quotation marks.
 * If inside the value a  has been identified, the apostrophe   is kept.
 * It is not possible that both quotation mark and apostrophe shall occur in a wikitext and a syntax error (missing delimiter) is assumed, triggering an error message.
 * or  enclosed in quotation marks are not accepted.
 * Leading and trailing whitespace within the value encosed by quotation marks will be removed.
 * Assignments of empty values are invalid and cause an error message. This goes not for occasional single attributes without equal sign (which are quite rare).
 * Before and ahead an attribute assignment there is exacly one space.
 * In case of multi-line tags line breaks are kept.

Nesting
Associated opening and closing tags are identified.

Correct nesting is checked; if end tags are missing or superfluous in a level an error message is thrown.

Some elements are processed immediately from opening until closing tag.

Content analysis

 * ranges and some (unary) elements will be protected immediately after regions which are commented out.
 * areas will be protected next and entirely.
 * If possible (key word „syntaxhighlight“ not within range) the obsoleted  is turned into   . By the way, the   tag is standardized as.
 * For security reasons HTML elements with URL links out of wiki projects (like  or  ) are blocked in the generated HTML page. Within wikitext the script will deactivate them by transformation of the leading   into , which yields the same optical appearance.
 * If typographical tags are met in unary shape, which is meaningful in binary mode only (like &lt;b />, &lt;em />, &lt;i />, &lt;span /> etc.), a certain bad habit is assumed and they are turned into . Parameters would be pointless and will be removed.
 * On activities in, which use the CSS property  … or contain the non-standard  …, only the block element   is possible and   will be transformed respectively. Non-standard forms in   are interpreted and according to the intention proper   etc. will be assigned.
 * In order to ensure valid HTML   is written as empty.
 * If an attribute assignment is mandatory or might not be permitted, an error message is shown.
 * With elements  well-known parameters are tolerated only.
 * If the kind of element suggests more specific processing, whitespace formatting, syntax analysis or possibly content protection, this is done or prebooked.

Comments

 * For the beginning of a comment  the adjacent end   is searched. If the end cannot be found or there is a space detected within the beginning of a comment an error message is displayed.
 * A comment may be subject to a user defined comment modification.
 * All comments will be protected against any further searching and replacement.

Remarks
&#91; German page &#93;