File: proposal.md

package info (click to toggle)
ruby-maruku 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,296 kB
  • ctags: 492
  • sloc: ruby: 5,726; xml: 235; makefile: 2
file content (309 lines) | stat: -rw-r--r-- 6,781 bytes parent folder | download | duplicates (5)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
CSS: style.css
LaTeX_use_listings: true
html_use_syntax: true
use_numbered_headers: true

Proposal for adding a meta-data syntax to Markdown
=============================================

This document describes a syntax for attaching meta-data to
block-level elements (headers, paragraphs, code blocks,…), 
and to span-level elements (links, images,…).

***Note: this is an evolving proposal***

Last updated **January 10th, 2007**: 

*	Changed the syntax for compatibility with a future extension mechanism.

	The first character in the curly braces must be a colon, optionally
	followed by a space:
	
		{: ref .class #id}
	
	The old syntax was `{ref .class #id}`.
	
	For ALDs, the new syntax is:
	
		{:ref_id: key=val .class #id }
	
	instead of:
	
		{ref_id}: key=val .class #id 

	Converters that don't use this syntax may just ignore everything
	which is in curly braces and starts with ":".

*	IAL can be put both *before* and *after* the element.
	There is no ambiguity as a blank line is needed between elements:
	
		Paragraph 1
		
		{:par2}
		Paragraph 2

	is equivalent to:
	
		Paragraph 1
	
		Paragraph 2
		{:par2}

*	Simplified rules for escaping.

*Table of contents:*

> * Table of contents
> {:toc}

Overview
--------

This proposal describes two additions to the Markdown syntax:

1. inline attribute lists (IAL)

   	## Header ##       {: key=val .class #id ref_id}

2. attribute lists definitions (ALD)

   	{:ref_id: key=val .class #id}

Every span-level or block-level element can be followed by an IAL:

	### Header ###     {: #header1 class=c1}
	
	Paragraph *with emphasis*{: class=c1}
	second line of paragraph
	{: class=c1}

In this example, the three IALs refer to the header, the emphasis span, and the entire paragraph, respectively.

IALs can reference ALDs. The result of the following example is the same as the previous one:

	### Header ###  {: #header1 c1}

	Paragraph *with emphasis*{:c1}
	second line of paragraph
	{:c1}
	
	{:c1: class=c1}

Attribute lists
---------------

This is an example attribute list, which shows
everything you can put inside:

	{: key1=val key2="long val" #myid .class1 .class2 ref1 ref2}

More in particular, an attribute list is a   whitespace-separated list 
of elements of 4 different kinds:

1. key/value pairs (quoted if necessary)
2. [references to ALD](#using_tags) (`ref1`,`ref2`)
3. [id specifiers](#class_id) (`#myid`)
4. [class specifiers](#class_id) (`.myclass`) 

### `id` and `class` are special ### {#class_id}

For ID and classes there are special shortcuts:

* `#myid` is a shortcut for `id=myid`
* `.myclass` means "add `myclass` to the current `class` attribute".

  So these are equivalent:

  	{: .class1 .class2}
  	{: class="class1 class2"}


The following attribute lists are equivalent:

	{: #myid .class1 .class2} 
	{: id=myid class=class1 .class2}
	{: id=myid class="class1 class2"}
	{: id=myid class="will be overridden" class=class1 .class2}

Where to put inline attribute lists
----------------------------------

### For block-level elements ###

For paragraphs and other block-level elements, IAL go
**after** the element:

	This is a paragraph.
	Line 2 of the paragraph.
	{: #myid .myclass}
	
	A quote with a citation url:
	> Who said that?
	{: cite=google.com}

Note: empty lines between the block and the IAL are not tolerated.
So this is not legal:

	This is a paragraph.
	Line 2 of the paragraph.
	
	{: #myid .myclass}

Attribute lists may be indented up to 3 spaces:

	Paragraph1
	 {:ok}
	
	Paragraph2
	  {:ok}
	
	Paragraph2
	   {:ok}
{:code_show_spaces}

### For headers ###

For headers, you can put attribute lists on the same line:

	### Header ###     {: #myid}

	Header     {: #myid .myclass}
	------

or, as like other block-level elements, on the line below:

	### Header ###     
	{: #myid}

	Header     
	------
	{: #myid .myclass}

### For span-level elements ###

For span-level elements, meta-data goes immediately **after** in the 
flow.

For example, in this:

	This is a *chunky paragraph*{: #id1}
	{: #id2}
	
the ID of the `em` element is set to `id1`
and the ID of the paragraph is set to `id2`.

This works also for links, like this:

	This is [a link][ref]{:#myid rel=abc rev=abc}

For images, this:

	This is ![Alt text](url "fresh carrots")

is equivalent to:
	
	This is ![Alt text](url){:title="fresh carrots"}

Using attributes lists definition    {#using_tags}
---------------------------------

In an attribute list, you can have: 

1. `key=value` pairs,
2. id attributes (`#myid`)
3. class attributes (`.myclass`) 

Everything else is interpreted as a reference to 
an ALD.

	# Header #      {:ref}

	Blah blah blah.
	
	{:ref: #myhead .myclass lang=fr}

Of course, more than one IAL can reference the same ALD:

	# Header 1 #      {:1}
	...
	# Header 2 #      {:1}

	{:1: .myclass lang=fr}


The rules           {:#grammar}
---------

### The issue of escaping ###

1.	No escaping in code spans/blocks.

2.	Everywhere else, **all** PUNCTUATION characters **can** be escaped,
and **must** be escaped when they could trigger links, tables, etc.
	
	A punctuation character is anything not a letter, a number, or whitespace
	(`[^a-zA-Z0-9\s\n]`).

3.	As a rule, quotes **must** be escaped inside quoted values:

	* Inside `"quoted values"`, you **must** escape `"`.
	* Inside `'quoted values'`, you **must** escape `'`.

	* Other examples:

	`"bah 'bah' bah"` =  `"bah \'bah\' bah"` = `'bah \'bah\' bah'`

	`'bah "bah" bah'` =  `'bah \"bah\" bah'` = `"bah \"bah\" bah"`


4.	There is an exception for backward compatibility, in links/images titles:

       [text](url "title"with"quotes")

	The exception is not valid for attribute lists and in other
	contexts, where you have to use the canonical syntax.


### Syntax for attribute lists ####

Consider the following attribute list:

	{: key=value ref key2="quoted value" }
	
In this string, `key`, `value`, and `ref` can be substituted by any
string that does not contain whitespace, or the unescaped characters `}`,`=`,`'`,`"`.

Inside a quoted value you **must** escape the other kind of quote.

Also, you **must** escape a closing curly brace `}` inside quoted values.
This rule is for making life easier for interpreter that just want to skip
the meta-data.

If you don't implement this syntax, you can get rid of the IAL by using this 
regular expression (this is written in Ruby):

	r = /\{:(\\\}|[^\}])*\}/       
	
	s.gsub(r, '') # ignore metadata
{:ruby}

Basically: match everything contained in a couple of `{:` and `}`, taking care
of escaping of `}`. This `\\\}|[^\}]` means: eat either any character which
is not a `}` or an escape sequence `\}`.

For this example,

	this is 
	{: skipped="\}" val=\} bar} 
	
	for me 
	{: also this} 

the result is:

	this is 
	 
	
	for me