Code block parsing
nav_first.pngFirst: thread:131
HTML Block
Edited: 11 Oct 2012 12:06 by: GoVegan
Comments: 0
nav_prev.pngPrevious: thread:229
CSS class added to document while editing
Edited: 06 Jan 2010 08:56 by: pieterh
Comments: 0
Last: thread:112
Image Module
Edited: 12 Nov 2009 12:22 by: pieterh
Comments: 0
Next: thread:116
Watchers module
Edited: 26 Dec 2009 13:19 by: pieterh
Comments: 0

pieterhpieterh 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 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

Other symbols By Gabrys 0 Comments 24 Mar 2010 18:33
No end marking? By Steven Heynderickx 1 Comments 30 Dec 2009 14:25
Problems with a single \ By Gabrys 2 Comments 22 Dec 2009 12:49

Comments: 0

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License