pieterh wrote on 22 Dec 2009 12:07
This is a design sketch for code block parsing.
Currently, code blocks are parsed in different and incomplete ways when (a) being rendered on a page and (b) being extracted via a /code/n URL. In the first case, include statements are processed. In the second case, they are not.
This design sketch covers the following use cases:
- Being able to construct code blocks out of included fragments, e.g. to build a CSS stylesheet out of pieces of CSS code hosted on another site. Example: I want to build a theme by including pieces from css.wikidot.com and then adding my own tweaks for color.
- Being able to properly render examples that use the include statement. Today this is not possible. Include statements are processed unless we add a dummy whitespace at the start or end of the line. But copying/pasting the rendered code also copies this whitespace, making the example unusable.
- Being able to highlight individual lines in the code block. Use case: I want to indicate an added or removed line in a code block.
The general solution is per-line escaping using a backslash+space "\ " at the start of the line. This can be rapidly processed by the parser. Backslashes anywhere except at the start of the line are treated like normal characters.
- A single backslash "\ " escapes the entire line so that it is not processed. The line is rendered/extracted without the backslash.
- "\\ " is rendered/extracted as a '\'.
- "\b " renders the line as bold. In extraction, the "\b " is dropped.
- "\u " renders the line as underlined. In extraction, the "\u " is dropped.
- "\s " renders the line as strike-out. In extraction, the "\s " dropped.
- "\i " renders the line as italic. In extraction the "\i " is dropped.
If the line is not escaped, [[include ]] statements are processed both during rendering and extraction.
Start a new sub-thread
page revision: 2, last edited: 30 Dec 2009 13:42