summaryrefslogtreecommitdiffstats
path: root/cnm-specification.cnm
blob: 8808481c57148c9b5bd21d600b80406fd70f7981 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
title
	CNM 0.1

content
	text fmt
		This is an archived copy of the original draft of the ContNet Markup from 2013. It has never been implemented and contains numerous flaws.

	raw text/cnm
		title
			Title goes here

		links
			http://whatever.com/ Whatever.com on HTTP
			cnp://something.net/else/
			../another-link

		site
			page1 Page 1
			another-page Just Another Page
			test This maps to /test
				foo and this to /test/foo
					bar.txt this is /test/foo/bar.txt file
				baz.jpg again in /test/foo/baz.jpg
				quux
				qwe the above page is shown as "quux"

		references
			cnp://this.is/a/reference ref1 Explanation of the reference
			/some/file ref2

		content
			section The format
				This is the ContNet content format. It is designed to be easy to write and parse,
				as well as to be readable without any formatting.

			section Features
				list
					- simple to parse by computers
					- simple to generate with scripts
					- easy to write manually
					- raw documents are readable
					- no layout definitions, only content
					- sections
					- lists
					- [[/some/page/ links]]
					- [[@ref1 references]]
					- [[#Features section references]]
					- UTF-8 with LF newlines

			section Layout
				The document is split into several blocks.

				Each block is indented by a tab character. The block lasts until the first
				line that contains something besides tabs that has lesser or equal
				indentation to the block declaration. Indenting a block with more than one
				tab is an error. Blank lines can be indented or not and will act the same
				(end the paragraph).

				A block declaration is the line after which a new indentation level is added.

				section Top level blocks
					The outtermost block can contain only the top-level blocks and these can
					only appear in that block:
					list
						- title: The page title, a single string (optionally even multiline).
						- links: A list of URLs and paths that can point to anywhere.
						These could be displayed in, for example, the top menu below the title.
						- site: A map of the current website. Consists of the basename of the file
						or folder optionally followed by a name to show instead of the filename.
						Each entry can have other entries nested.
						- references: A list of URLs and paths with identifiers. These can be
						later referenced in the link context with the identifier prefixed by the @
						character. When used without link text, references could be rendered as,
						for example, Wikipedia-style [1] references. The reference's URL can be
						#, the empty bookmark, if the reference doesn't contain a link.
						- content: Contains the main section of the page. The top level of content
						can contain only sections.

					Multiple top-level blocks of the same type are concatenated together as if
					they were one block. This may be undesirable for the title block, as it will
					add a newline.

				section Content blocks
					list
						- section: Optionally named section of the content. Can be nested in other
						sections. This is the only block that can be on the top level. If a name
						is provided, it is displayed as the section title and can be referenced
						as an in-page bookmark in the link context using the name identifier
						prefixed with the # character. A section is a generic container for other
						blocks or text.
						- table: Defines a table. The first line in the table defines the table
						header, the rest are cells. Columns are prefixed with the | character.
						Each row ends in a newline. To omit the header, leave its cells blank.
						The number of columns in the table is equal to the longest row's. If a
						line does not begin with |, it's considered to be a continuation of	the
						previous row's last cell. That way, multi-paragraph cells are possible.
						- code: All text inside this block is displayed as it is, without any
						parsing being done. This includes additional indents. Optionally, the
						language can be specified as a parameter to the block definition, so that
						a client that supports syntax highlighting can format that code. The
						language name should be the lowercase primary filename extension for a file
						containing such source code, such as "c", "js", "cpp", "cob" and "cl".
						- list: An unordered list. Each item starts with a - on the start of a
						line and lasts until the next item or the end of the list block. Each
						list item acts as a section, so it's possible to nest blocks in them.

					section Paragraphs
						A paragraph is text that is not a block. It lasts until a blank line, the
						end of the current block or the start of a new block. The lines within a
						paragraph will be joined with spaces. Paragraphs can be in any text
						context, such as in list items, table cells, link text, etc.

					section Text
						Text appears within paragraph. It should be UTF-8 encoded. It can contain
						any characters that are not part of the syntax. Notably, the only
						characters that can't be included by escaping are tabs on start of a line
						and the newline character. Whitespace is collapsed.

						Text can be bold (toggle with \*\*) and italic (\_\_). Once toggled, the
						style will last until it is toggled again or the end of the paragraph.

					section Tables
						This format supports tables:

						table
							| column1 | column2
							| row     | 1
							| row     | 2
					
					section Links
						A link can be added inline using the link context:

						code
							[[path text to display]]

						The "path" can be an URL or a CNP relative or absolute path, as well as
						a reference when prefixed with @ and a bookmark when prefixed with #.

						"text to display" is the text to which the link is added. If omitted or
						blank, the path will be shown.

					section Escaping
						URLs, both cnp:// and others, have to be escaped using the standard URL
						escaping.

						CNP paths have to be escaped just like in the ContNet protocol:
						table
							| character | escape sequence
							| space     | \\_
							| newline   | \\n
							| NUL       | \\0
							| backslash | \\\\

						Various parts of the syntax can be escaped too:
						table
							| character  | escape sequence
							| table \|   | \\|
							| list -     | \\-
							| asterisk   | \\*
							| underscore | \\_
							| link \[    | \\\[
							| link \]    | \\\]
							| backslash  | \\\\

			section TODO
				list
					- Embedded content
					- Metadata
					- TODO