maruku 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/maruku +74 -22
- data/bin/marutest +15 -3
- data/docs/{changelog-0.3.md → changelog.md} +47 -18
- data/docs/entity_test.html +253 -0
- data/docs/entity_test.md +21 -0
- data/docs/index.html +124 -31
- data/docs/markdown_syntax.html +46 -46
- data/docs/maruku.html +124 -31
- data/docs/maruku.md +47 -9
- data/docs/proposal.html +4 -4
- data/lib/maruku.rb +1 -0
- data/lib/maruku/defaults.rb +1 -1
- data/lib/maruku/helpers.rb +4 -4
- data/lib/maruku/input/parse_block.rb +39 -33
- data/lib/maruku/input/parse_doc.rb +57 -3
- data/lib/maruku/input/parse_span_better.rb +28 -8
- data/lib/maruku/input/rubypants.rb +225 -0
- data/lib/maruku/input/type_detection.rb +1 -0
- data/lib/maruku/output/to_html.rb +46 -47
- data/lib/maruku/output/to_latex.rb +166 -45
- data/lib/maruku/output/to_latex_entities.rb +75 -43
- data/lib/maruku/string_utils.rb +21 -19
- data/lib/maruku/structures.rb +21 -12
- data/lib/maruku/structures_inspect.rb +12 -3
- data/lib/maruku/tests/new_parser.rb +2 -1
- data/lib/maruku/version.rb +1 -1
- data/tests/unittest/abbreviations.md +8 -8
- data/tests/unittest/attributes/attributes.md +10 -10
- data/tests/unittest/attributes/circular.md +4 -4
- data/tests/unittest/attributes/default.md +3 -3
- data/tests/unittest/blank.md +2 -2
- data/tests/unittest/blanks_in_code.md +12 -12
- data/tests/unittest/code.md +4 -4
- data/tests/unittest/code2.md +7 -6
- data/tests/unittest/code3.md +16 -16
- data/tests/unittest/easy.md +4 -4
- data/tests/unittest/email.md +4 -4
- data/tests/unittest/encoding/iso-8859-1.md +2 -2
- data/tests/unittest/encoding/utf-8.md +2 -2
- data/tests/unittest/entities.md +20 -20
- data/tests/unittest/escaping.md +16 -16
- data/tests/unittest/extra_dl.md +17 -7
- data/tests/unittest/extra_header_id.md +11 -11
- data/tests/unittest/extra_table1.md +4 -4
- data/tests/unittest/footnotes.md +38 -28
- data/tests/unittest/headers.md +6 -6
- data/tests/unittest/hrule.md +6 -6
- data/tests/unittest/images.md +18 -16
- data/tests/unittest/inline_html.md +7 -29
- data/tests/unittest/inline_html2.md +3 -3
- data/tests/unittest/links.md +7 -27
- data/tests/unittest/list1.md +9 -8
- data/tests/unittest/list2.md +15 -12
- data/tests/unittest/list3.md +16 -14
- data/tests/unittest/list4.md +4 -4
- data/tests/unittest/lists.md +33 -29
- data/tests/unittest/lists_after_paragraph.md +36 -36
- data/tests/unittest/lists_ol.md +43 -38
- data/tests/unittest/misc_sw.md +172 -156
- data/tests/unittest/notyet/escape.md +8 -8
- data/tests/unittest/notyet/header_after_par.md +6 -6
- data/tests/unittest/notyet/ticks.md +4 -4
- data/tests/unittest/notyet/triggering.md +21 -21
- data/tests/unittest/olist.md +5 -5
- data/tests/unittest/one.md +1 -1
- data/tests/unittest/paragraph.md +1 -1
- data/tests/unittest/paragraph_rules/dont_merge_ref.md +1 -1
- data/tests/unittest/paragraph_rules/tab_is_blank.md +2 -2
- data/tests/unittest/paragraphs.md +5 -5
- data/tests/unittest/recover/recover_links.md +2 -2
- data/tests/unittest/references/long_example.md +27 -19
- data/tests/unittest/smartypants.md +148 -0
- data/tests/unittest/syntax_hl.md +14 -14
- data/tests/unittest/test.md +2 -2
- data/tests/unittest/wrapping.md +8 -8
- data/tests/unittest/xml_instruction.md +82 -0
- metadata +149 -160
- data/docs/TOFIX.html +0 -22
- data/docs/TOFIX.md +0 -3
- data/docs/changelog-0.2.13.html +0 -30
- data/docs/changelog-0.2.13.md +0 -6
- data/docs/changelog-0.3.html +0 -113
- data/docs/faq.html +0 -57
- data/docs/faq.md +0 -32
- data/docs/hidden_o_n_squared.md +0 -10
- data/docs/todo.html +0 -40
- data/docs/todo.md +0 -9
data/lib/maruku/string_utils.rb
CHANGED
@@ -32,10 +32,21 @@ module MaRuKu; module Strings
|
|
32
32
|
s.split("\n")
|
33
33
|
end
|
34
34
|
|
35
|
-
# This parses email headers. Returns an hash.
|
35
|
+
# This parses email headers. Returns an hash.
|
36
|
+
#
|
37
|
+
# +hash['data']+ is the message.
|
38
|
+
#
|
39
|
+
# Keys are downcased, space becomes underscore, converted to symbols.
|
40
|
+
#
|
41
|
+
# My key: true
|
42
|
+
#
|
43
|
+
# becomes:
|
44
|
+
#
|
45
|
+
# {:my_key => true}
|
46
|
+
#
|
36
47
|
def parse_email_headers(s)
|
37
48
|
keys={}
|
38
|
-
match = (s =~ /((\w+: .*\n)+)\n/)
|
49
|
+
match = (s =~ /((\w[\w\s]+: .*\n)+)\n/)
|
39
50
|
if match != 0
|
40
51
|
keys[:data] = s
|
41
52
|
else
|
@@ -51,27 +62,18 @@ module MaRuKu; module Strings
|
|
51
62
|
end
|
52
63
|
keys
|
53
64
|
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# `#xyz` => id: xyz
|
65
|
+
|
66
|
+
# Keys are downcased, space becomes underscore, converted to symbols.
|
57
67
|
def normalize_key_and_value(k,v)
|
58
68
|
v = v ? v.strip : true # no value defaults to true
|
59
69
|
k = k.strip
|
60
70
|
|
61
|
-
#
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
else
|
68
|
-
# check synonyms
|
69
|
-
v = true if ['yes','true'].include?(v.to_s.downcase)
|
70
|
-
v = false if ['no','false'].include?(v.to_s.downcase)
|
71
|
-
|
72
|
-
k = k.downcase.gsub(' ','_')
|
73
|
-
return k, v
|
74
|
-
end
|
71
|
+
# check synonyms
|
72
|
+
v = true if ['yes','true'].include?(v.to_s.downcase)
|
73
|
+
v = false if ['no','false'].include?(v.to_s.downcase)
|
74
|
+
|
75
|
+
k = k.downcase.gsub(' ','_')
|
76
|
+
return k, v
|
75
77
|
end
|
76
78
|
|
77
79
|
# Returns the number of leading spaces, considering that
|
data/lib/maruku/structures.rb
CHANGED
@@ -21,14 +21,15 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
class Module
|
24
|
-
def
|
24
|
+
def safe_attr_accessor1(symbol, klass)
|
25
25
|
attr_reader symbol
|
26
26
|
code = <<-EOF
|
27
27
|
def #{symbol}=(val)
|
28
28
|
if not val.kind_of? #{klass}
|
29
|
-
s = "
|
30
|
-
s += "Tried to assign
|
31
|
-
|
29
|
+
s = "\nCould not assign an object of type \#{val.class} to #{symbol}.\n\n"
|
30
|
+
s += "Tried to assign object of class \#{val.class}:\n"+
|
31
|
+
"\#{val.inspect}\n"+
|
32
|
+
"to \#{self.class}::#{symbol} constrained to be of class #{klass}.\n"
|
32
33
|
raise s
|
33
34
|
end
|
34
35
|
@#{symbol} = val
|
@@ -38,12 +39,19 @@ EOF
|
|
38
39
|
module_eval code
|
39
40
|
end
|
40
41
|
|
41
|
-
def
|
42
|
+
def safe_attr_accessor2(symbol, klass)
|
42
43
|
attr_accessor symbol
|
43
44
|
end
|
45
|
+
|
46
|
+
alias safe_attr_accessor safe_attr_accessor1
|
44
47
|
end
|
45
48
|
|
46
49
|
module MaRuKu
|
50
|
+
|
51
|
+
Globals = {
|
52
|
+
:unsafe_features => false,
|
53
|
+
}
|
54
|
+
|
47
55
|
# I did not want to have a class for each possible element.
|
48
56
|
# Instead I opted to have only the class "MDElement"
|
49
57
|
# that represents eveything in the document (paragraphs, headers, etc).
|
@@ -56,8 +64,8 @@ module MaRuKu
|
|
56
64
|
# The @doc variable points to the document to which the MDElement
|
57
65
|
# belongs (which is an instance of Maruku, subclass of MDElement).
|
58
66
|
#
|
59
|
-
#
|
60
|
-
# spaces substituted by underscores)
|
67
|
+
# Attributes are contained in the hash `attributes`.
|
68
|
+
# Keys are symbols (downcased, with spaces substituted by underscores)
|
61
69
|
#
|
62
70
|
# For example, if you write in the source document.
|
63
71
|
#
|
@@ -68,19 +76,16 @@ module MaRuKu
|
|
68
76
|
#
|
69
77
|
# You can access `value` by writing:
|
70
78
|
#
|
71
|
-
# @doc.
|
79
|
+
# @doc.attributes[:my_property] # => 'value'
|
72
80
|
#
|
73
81
|
# from whichever MDElement in the hierarchy.
|
74
|
-
|
82
|
+
#
|
75
83
|
class MDElement
|
76
84
|
# See helpers.rb for the list of allowed #node_type values
|
77
85
|
safe_attr_accessor :node_type, Symbol
|
78
86
|
|
79
87
|
# Children are either Strings or MDElement
|
80
88
|
safe_attr_accessor :children, Array
|
81
|
-
|
82
|
-
|
83
|
-
# safe_attr_accessor :meta, Hash
|
84
89
|
|
85
90
|
# An attribute list, may not be nil
|
86
91
|
safe_attr_accessor :al, Array #Maruku::AttributeList
|
@@ -129,6 +134,7 @@ end
|
|
129
134
|
# This represents the whole document and holds global data.
|
130
135
|
|
131
136
|
class MDDocument
|
137
|
+
|
132
138
|
safe_attr_accessor :refs, Hash
|
133
139
|
safe_attr_accessor :footnotes, Hash
|
134
140
|
|
@@ -141,6 +147,8 @@ class MDDocument
|
|
141
147
|
# The order in which footnotes are used. Contains the id.
|
142
148
|
safe_attr_accessor :footnotes_order, Array
|
143
149
|
|
150
|
+
safe_attr_accessor :latex_required_packages, Array
|
151
|
+
|
144
152
|
def initialize(s=nil)
|
145
153
|
super(:document)
|
146
154
|
@doc = self
|
@@ -150,6 +158,7 @@ class MDDocument
|
|
150
158
|
self.footnotes_order = []
|
151
159
|
self.abbreviations = {}
|
152
160
|
self.ald = {}
|
161
|
+
self.latex_required_packages = []
|
153
162
|
|
154
163
|
parse_doc(s) if s
|
155
164
|
end
|
@@ -21,7 +21,15 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
class String
|
24
|
-
|
24
|
+
def inspect_more(a=nil,b=nil)
|
25
|
+
inspect
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Object
|
30
|
+
def inspect_more(a=nil,b=nil)
|
31
|
+
inspect
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
class Array
|
@@ -37,8 +45,9 @@ class Array
|
|
37
45
|
end
|
38
46
|
|
39
47
|
class Hash
|
40
|
-
def inspect_ordered
|
41
|
-
"{"+map{|
|
48
|
+
def inspect_ordered(a=nil,b=nil)
|
49
|
+
"{"+keys.map{|x|x.to_s}.sort.map{|x|x.to_sym}.
|
50
|
+
map{|k| k.inspect + "=>"+self[k].inspect}.join(',')+"}"
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
@@ -224,7 +224,8 @@ module MaRuKu; module Tests
|
|
224
224
|
["a<!--", :throw, 'Bad HTML Comment'],
|
225
225
|
["a<!-- ", :throw, 'Bad HTML Comment'],
|
226
226
|
|
227
|
-
["<? <?!--!`3 ?>", [
|
227
|
+
["<?xml <?!--!`3 ?>", [md_xml_instr('xml','<?!--!`3')], 'XML processing instruction'],
|
228
|
+
["<? <?!--!`3 ?>", [md_xml_instr('','<?!--!`3')] ],
|
228
229
|
|
229
230
|
["<? ", :throw, 'Bad Server directive'],
|
230
231
|
|
data/lib/maruku/version.rb
CHANGED
@@ -22,14 +22,14 @@ md_el(:document,[
|
|
22
22
|
md_el(:abbr,["W3C"],{:title=>"World Wide Web Consortium"},[]),
|
23
23
|
"."
|
24
24
|
]),
|
25
|
-
md_el(:abbr_def,[],{:text=>"Hyper Text Markup Language"
|
26
|
-
md_el(:abbr_def,[],{:text=>"World Wide Web Consortium"
|
25
|
+
md_el(:abbr_def,[],{:abbr=>"HTML",:text=>"Hyper Text Markup Language"},[]),
|
26
|
+
md_el(:abbr_def,[],{:abbr=>"W3C",:text=>"World Wide Web Consortium"},[]),
|
27
27
|
md_par([
|
28
28
|
"Operation ",
|
29
29
|
md_el(:abbr,["Tigra Genesis"],{:title=>nil},[]),
|
30
30
|
" is going well."
|
31
31
|
]),
|
32
|
-
md_el(:abbr_def,[],{:
|
32
|
+
md_el(:abbr_def,[],{:abbr=>"Tigra Genesis",:text=>nil},[])
|
33
33
|
],{},[])
|
34
34
|
*** Output of to_html ***
|
35
35
|
|
@@ -75,8 +75,8 @@ The HTML specification is maintained by the W3C.Operation Tigra Genesis is going
|
|
75
75
|
|
76
76
|
*** Output of Markdown.pl (parsed) ***
|
77
77
|
<p>The HTML specification is maintained by the W3C.</p
|
78
|
-
|
79
|
-
*[W3C]:
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
><p>*[HTML]: Hyper Text Markup Language
|
79
|
+
*[W3C]: World Wide Web Consortium</p
|
80
|
+
><p>Operation Tigra Genesis is going well.</p
|
81
|
+
><p>*[Tigra Genesis]:</p
|
82
|
+
>
|
@@ -27,7 +27,7 @@ md_el(:document,[
|
|
27
27
|
md_em(["emphasis"], [[:ref, "hello"], [:ref, "notfound"]]),
|
28
28
|
md_ial([[:ref, "hello"], [:ref, "notfound"]])
|
29
29
|
], [[:id, "par2"]]),
|
30
|
-
md_el(:ald,[],{:
|
30
|
+
md_el(:ald,[],{:ald=>[[:class, "chello"]],:ald_id=>"hello"},[])
|
31
31
|
],{},[])
|
32
32
|
*** Output of to_html ***
|
33
33
|
|
@@ -77,13 +77,13 @@ Header with attributesHeader with attributesHeader no attributesParagraph with e
|
|
77
77
|
<p>{hello}: .chello</p>
|
78
78
|
|
79
79
|
*** Output of Markdown.pl (parsed) ***
|
80
|
-
<h2>Header with attributes
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
<h2>Header with attributes {#header1} </h2
|
81
|
+
><h3>Header with attributes ### {#header2}</h3
|
82
|
+
><h3>Header no attributes</h3
|
83
|
+
><p>{warn2}Paragraph with a.
|
84
84
|
{#par1}</p
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
><p>Paragraph with <em>emphasis</em
|
86
|
+
>{hello notfound}
|
87
|
+
{#par2}</p
|
88
|
+
><p>{hello}: .chello</p
|
89
|
+
>
|
@@ -13,8 +13,8 @@ Paragraph
|
|
13
13
|
*** Output of inspect ***
|
14
14
|
md_el(:document,[
|
15
15
|
md_par(["Paragraph"], [[:ref, "a"]]),
|
16
|
-
md_el(:ald,[],{:
|
17
|
-
md_el(:ald,[],{:
|
16
|
+
md_el(:ald,[],{:ald=>[[:ref, "b"]],:ald_id=>"a"},[]),
|
17
|
+
md_el(:ald,[],{:ald=>[[:ref, "a"]],:ald_id=>"b"},[])
|
18
18
|
],{},[])
|
19
19
|
*** Output of to_html ***
|
20
20
|
|
@@ -46,6 +46,6 @@ Paragraph
|
|
46
46
|
*** Output of Markdown.pl (parsed) ***
|
47
47
|
<p>Paragraph
|
48
48
|
{a}</p
|
49
|
-
|
49
|
+
><p>{a}: b
|
50
50
|
{b}: a</p
|
51
|
-
|
51
|
+
>
|
@@ -10,7 +10,7 @@ Paragraph2
|
|
10
10
|
*** Output of inspect ***
|
11
11
|
md_el(:document,[
|
12
12
|
md_par(["Paragraph2"], [[:id, "2"]]),
|
13
|
-
md_el(:ald,[],{:
|
13
|
+
md_el(:ald,[],{:ald=>[[:class, "maruku-par"]],:ald_id=>"paragraph"},[])
|
14
14
|
],{},[])
|
15
15
|
*** Output of to_html ***
|
16
16
|
|
@@ -43,5 +43,5 @@ Paragraph2
|
|
43
43
|
*** Output of Markdown.pl (parsed) ***
|
44
44
|
<p>Paragraph2
|
45
45
|
{#2}</p
|
46
|
-
|
47
|
-
|
46
|
+
><p>{paragraph}: .maruku-par</p
|
47
|
+
>
|
data/tests/unittest/blank.md
CHANGED
@@ -109,23 +109,23 @@ four
|
|
109
109
|
|
110
110
|
*** Output of Markdown.pl (parsed) ***
|
111
111
|
<p>This block is composed of three lines:</p
|
112
|
-
|
113
|
-
|
112
|
+
><pre
|
113
|
+
><code>one
|
114
114
|
|
115
115
|
three
|
116
116
|
</code
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
></pre
|
118
|
+
><p>This block is composed of 5</p
|
119
|
+
><pre
|
120
|
+
><code>one
|
121
121
|
|
122
122
|
|
123
123
|
four
|
124
124
|
</code
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
></pre
|
126
|
+
><p>This block is composed of 2</p
|
127
|
+
><pre
|
128
|
+
><code>two
|
129
129
|
</code
|
130
|
-
|
131
|
-
|
130
|
+
></pre
|
131
|
+
>
|
data/tests/unittest/code.md
CHANGED
@@ -54,11 +54,11 @@ end tell
|
|
54
54
|
|
55
55
|
*** Output of Markdown.pl (parsed) ***
|
56
56
|
<p>Here is an example of AppleScript:</p
|
57
|
-
|
58
|
-
|
57
|
+
><pre
|
58
|
+
><code>tell application "Foo"
|
59
59
|
beep
|
60
60
|
end tell
|
61
61
|
tab
|
62
62
|
</code
|
63
|
-
|
64
|
-
|
63
|
+
></pre
|
64
|
+
>
|
data/tests/unittest/code2.md
CHANGED
data/tests/unittest/code3.md
CHANGED
@@ -99,23 +99,23 @@ This is code (4 spaces):This is not codeThis is code (1 tab):This is not code
|
|
99
99
|
|
100
100
|
*** Output of Markdown.pl (parsed) ***
|
101
101
|
<p>This is code (4 spaces):</p
|
102
|
-
|
103
|
-
|
102
|
+
><pre
|
103
|
+
><code>Code
|
104
104
|
</code
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
></pre
|
106
|
+
><p>This is not code</p
|
107
|
+
><pre
|
108
|
+
><code>Code
|
109
109
|
</code
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
></pre
|
111
|
+
><p>This is code (1 tab):</p
|
112
|
+
><pre
|
113
|
+
><code>Code
|
114
114
|
</code
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
></pre
|
116
|
+
><p>This is not code</p
|
117
|
+
><pre
|
118
|
+
><code>Code
|
119
119
|
</code
|
120
|
-
|
121
|
-
|
120
|
+
></pre
|
121
|
+
>
|
data/tests/unittest/easy.md
CHANGED