maruku 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/docs/maruku.md +25 -1
- data/lib/maruku.rb +3 -0
- data/lib/maruku/string_utils.rb +17 -7
- data/lib/maruku/structures.rb +35 -3
- data/lib/maruku/to_latex_strings.rb +3 -3
- data/lib/maruku/version.rb +6 -0
- metadata +65 -70
data/docs/maruku.md
CHANGED
|
@@ -283,6 +283,29 @@ These can also be separated by newlines:
|
|
|
283
283
|
|
|
284
284
|
Paragraph 1 is a warning
|
|
285
285
|
|
|
286
|
+
|
|
287
|
+
### Shortcuts ###
|
|
288
|
+
|
|
289
|
+
This:
|
|
290
|
+
|
|
291
|
+
@ .xyz
|
|
292
|
+
Paragraph
|
|
293
|
+
|
|
294
|
+
is equivalent to:
|
|
295
|
+
|
|
296
|
+
@ class: xyz
|
|
297
|
+
Paragraph
|
|
298
|
+
|
|
299
|
+
This:
|
|
300
|
+
|
|
301
|
+
@ #xyz
|
|
302
|
+
Paragraph
|
|
303
|
+
|
|
304
|
+
is equivalent to:
|
|
305
|
+
|
|
306
|
+
@ id: xyz
|
|
307
|
+
Paragraph
|
|
308
|
+
|
|
286
309
|
Also, if the value is not present, it defaults to `true`:
|
|
287
310
|
|
|
288
311
|
@ test
|
|
@@ -293,8 +316,9 @@ Also, if the value is not present, it defaults to `true`:
|
|
|
293
316
|
|
|
294
317
|
|
|
295
318
|
|
|
319
|
+
@ #metalist
|
|
296
320
|
|
|
297
|
-
### List of meta-data ###
|
|
321
|
+
### List of meta-data ###
|
|
298
322
|
|
|
299
323
|
[listings]: http://www.ctan.org/tex-archive/macros/latex/contrib/listings/
|
|
300
324
|
|
data/lib/maruku.rb
CHANGED
data/lib/maruku/string_utils.rb
CHANGED
|
@@ -10,7 +10,7 @@ class Maruku
|
|
|
10
10
|
a
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
# This parses email headers. Returns an hash. hash['data'] is the message.
|
|
14
14
|
def parse_email_headers(s)
|
|
15
15
|
keys={}
|
|
16
16
|
match = (s =~ /((\w+: .*\n)+)\n/)
|
|
@@ -30,16 +30,26 @@ class Maruku
|
|
|
30
30
|
keys
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
# `.xyz` => class: xyz
|
|
34
|
+
# `#xyz` => id: xyz
|
|
33
35
|
def normalize_key_and_value(k,v)
|
|
34
36
|
v = v ? v.strip : true # no value defaults to true
|
|
35
|
-
|
|
36
|
-
# check synonyms
|
|
37
|
-
v = true if ['yes','true'].include?(v.to_s.downcase)
|
|
38
|
-
v = false if ['no','false'].include?(v.to_s.downcase)
|
|
37
|
+
k = k.strip
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
# `.xyz` => class: xyz
|
|
40
|
+
if k =~ /^\.([\w\d]+)/
|
|
41
|
+
return :class, $1
|
|
42
|
+
# `#xyz` => id: xyz
|
|
43
|
+
elsif k =~ /^\#([\w\d]+)/
|
|
44
|
+
return :id, $1
|
|
45
|
+
else
|
|
46
|
+
# check synonyms
|
|
47
|
+
v = true if ['yes','true'].include?(v.to_s.downcase)
|
|
48
|
+
v = false if ['no','false'].include?(v.to_s.downcase)
|
|
41
49
|
|
|
42
|
-
|
|
50
|
+
k = k.downcase.gsub(' ','_')
|
|
51
|
+
return k, v
|
|
52
|
+
end
|
|
43
53
|
end
|
|
44
54
|
|
|
45
55
|
# Returns the number of leading spaces, considering that
|
data/lib/maruku/structures.rb
CHANGED
|
@@ -1,13 +1,42 @@
|
|
|
1
|
+
# I did not want to have a class for each possible element.
|
|
2
|
+
# Instead I opted to have the class "MDElement"
|
|
3
|
+
# that represents eveything in the document (paragraphs, headers, etc).
|
|
4
|
+
#
|
|
5
|
+
# You can tell what it is by the variable `node_type`.
|
|
6
|
+
#
|
|
7
|
+
# In the instance-variable `children` there are the children. These
|
|
8
|
+
# can be of class 1) String or 2) MDElement.
|
|
9
|
+
#
|
|
10
|
+
# The @doc variable points to the document to which the MDElement
|
|
11
|
+
# belongs (which is an instance of Maruku, subclass of MDElement).
|
|
12
|
+
#
|
|
13
|
+
# Meta data is specified the hash `meta`. Keys are symbols (downcased, with
|
|
14
|
+
# spaces substituted by underscores)
|
|
15
|
+
#
|
|
16
|
+
# For example, if you write in the source document.
|
|
17
|
+
#
|
|
18
|
+
# Title: test document
|
|
19
|
+
# My property: value
|
|
20
|
+
#
|
|
21
|
+
# content content
|
|
22
|
+
#
|
|
23
|
+
# You can access `value` by writing:
|
|
24
|
+
#
|
|
25
|
+
# @doc.meta[:my_property] # => 'value'
|
|
26
|
+
#
|
|
27
|
+
# from whichever MDElement.
|
|
1
28
|
|
|
2
29
|
class MDElement
|
|
3
|
-
#
|
|
30
|
+
# XXX List not complete
|
|
31
|
+
# Allowed: :document, :paragraph, :ul, :ol, :li,
|
|
32
|
+
# :li_span, :strong, :emphasis, :link, :email
|
|
4
33
|
attr_accessor :node_type
|
|
5
34
|
# Children are either Strings or MDElement
|
|
6
35
|
attr_accessor :children
|
|
7
36
|
# Hash for metadata
|
|
8
37
|
# contains :id for :link1
|
|
9
38
|
# :li :want_my_paragraph
|
|
10
|
-
#
|
|
39
|
+
# :header: :level
|
|
11
40
|
# code, inline_code: :raw_code
|
|
12
41
|
attr_accessor :meta
|
|
13
42
|
# reference of containing document (document has list of ref)
|
|
@@ -34,8 +63,11 @@ class Maruku < MDElement
|
|
|
34
63
|
end
|
|
35
64
|
|
|
36
65
|
class MDElement
|
|
66
|
+
|
|
67
|
+
# This represents a section in the TOC.
|
|
37
68
|
class Section
|
|
38
|
-
|
|
69
|
+
# a Fixnum, is == header_element.meta[:level]
|
|
70
|
+
attr_accessor :section_level
|
|
39
71
|
|
|
40
72
|
# An array of fixnum, like [1,2,5] for Section 1.2.5
|
|
41
73
|
attr_accessor :section_number
|
|
@@ -20,9 +20,9 @@ class String
|
|
|
20
20
|
|
|
21
21
|
# other things that are good on the eyes
|
|
22
22
|
OtherGoodies = {
|
|
23
|
-
/(\s)LaTeX/ => '\1\\LaTeX\\xspace', # XXX not if already \latex
|
|
24
|
-
'HTML' => '\\textsc{html}\\xspace',
|
|
25
|
-
'PDF' => '\\textsc{pdf}\\xspace'
|
|
23
|
+
/(\s)LaTeX/ => '\1\\LaTeX\\xspace ', # XXX not if already \latex
|
|
24
|
+
'HTML' => '\\textsc{html}\\xspace ',
|
|
25
|
+
'PDF' => '\\textsc{pdf}\\xspace '
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
def String.convert_entities(s)
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.
|
|
2
|
+
rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: maruku
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.2.
|
|
7
|
-
date: 2006-12-27
|
|
6
|
+
version: 0.2.7
|
|
7
|
+
date: 2006-12-27
|
|
8
8
|
summary: A Markdown interpreter in Ruby
|
|
9
9
|
require_paths:
|
|
10
|
-
- lib
|
|
10
|
+
- lib
|
|
11
11
|
email: andrea@rubyforge.org
|
|
12
12
|
homepage: http://maruku.rubyforge.org
|
|
13
13
|
rubyforge_project:
|
|
@@ -18,80 +18,75 @@ bindir: bin
|
|
|
18
18
|
has_rdoc: false
|
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
20
|
requirements:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
-
|
|
22
|
+
- ">"
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: 0.0.0
|
|
24
25
|
version:
|
|
25
26
|
platform: ruby
|
|
26
|
-
signing_key:
|
|
27
|
-
cert_chain:
|
|
28
|
-
post_install_message:
|
|
29
27
|
authors:
|
|
30
|
-
- Andrea Censi
|
|
28
|
+
- Andrea Censi
|
|
31
29
|
files:
|
|
32
|
-
- lib/maruku.rb
|
|
33
|
-
- lib/maruku/parse_block.rb
|
|
34
|
-
- lib/maruku/parse_span.rb
|
|
35
|
-
- lib/maruku/string_utils.rb
|
|
36
|
-
- lib/maruku/structures.rb
|
|
37
|
-
- lib/maruku/to_html.rb
|
|
38
|
-
- lib/maruku/to_latex.rb
|
|
39
|
-
- lib/maruku/to_latex_strings.rb
|
|
40
|
-
- lib/maruku/to_s.rb
|
|
41
|
-
- lib/maruku/toc.rb
|
|
42
|
-
-
|
|
43
|
-
- docs/
|
|
44
|
-
- docs/
|
|
45
|
-
-
|
|
46
|
-
- tests/
|
|
47
|
-
- tests/
|
|
48
|
-
- tests/
|
|
49
|
-
- tests/
|
|
50
|
-
- tests/
|
|
51
|
-
- tests/
|
|
52
|
-
- tests/
|
|
53
|
-
- tests/
|
|
54
|
-
- tests/
|
|
55
|
-
- tests/
|
|
56
|
-
- tests/
|
|
57
|
-
- tests/
|
|
58
|
-
- tests/
|
|
59
|
-
- tests/
|
|
60
|
-
- tests/
|
|
61
|
-
- tests/
|
|
62
|
-
- tests/
|
|
63
|
-
- tests/
|
|
64
|
-
- tests/
|
|
65
|
-
- tests/
|
|
66
|
-
- tests/
|
|
67
|
-
- tests/
|
|
68
|
-
- tests/
|
|
69
|
-
- tests/
|
|
70
|
-
- tests/
|
|
71
|
-
- tests/
|
|
72
|
-
- tests/
|
|
73
|
-
-
|
|
74
|
-
- bin/
|
|
30
|
+
- lib/maruku.rb
|
|
31
|
+
- lib/maruku/parse_block.rb
|
|
32
|
+
- lib/maruku/parse_span.rb
|
|
33
|
+
- lib/maruku/string_utils.rb
|
|
34
|
+
- lib/maruku/structures.rb
|
|
35
|
+
- lib/maruku/to_html.rb
|
|
36
|
+
- lib/maruku/to_latex.rb
|
|
37
|
+
- lib/maruku/to_latex_strings.rb
|
|
38
|
+
- lib/maruku/to_s.rb
|
|
39
|
+
- lib/maruku/toc.rb
|
|
40
|
+
- lib/maruku/version.rb
|
|
41
|
+
- docs/markdown_syntax.md
|
|
42
|
+
- docs/maruku.md
|
|
43
|
+
- docs/todo.md
|
|
44
|
+
- tests/abbreviations.md
|
|
45
|
+
- tests/blank.md
|
|
46
|
+
- tests/code.md
|
|
47
|
+
- tests/code2.md
|
|
48
|
+
- tests/code3.md
|
|
49
|
+
- tests/email.md
|
|
50
|
+
- tests/entities.md
|
|
51
|
+
- tests/escaping.md
|
|
52
|
+
- tests/extra_dl.md
|
|
53
|
+
- tests/extra_header_id.md
|
|
54
|
+
- tests/extra_table1.md
|
|
55
|
+
- tests/footnotes.md
|
|
56
|
+
- tests/headers.md
|
|
57
|
+
- tests/hrule.md
|
|
58
|
+
- tests/images.md
|
|
59
|
+
- tests/inline_html.md
|
|
60
|
+
- tests/links.md
|
|
61
|
+
- tests/list1.md
|
|
62
|
+
- tests/list2.md
|
|
63
|
+
- tests/list3.md
|
|
64
|
+
- tests/lists.md
|
|
65
|
+
- tests/lists_ol.md
|
|
66
|
+
- tests/misc_sw.md
|
|
67
|
+
- tests/one.md
|
|
68
|
+
- tests/paragraphs.md
|
|
69
|
+
- tests/sss06.md
|
|
70
|
+
- tests/test.md
|
|
71
|
+
- tests/bugs/code_in_links.md
|
|
72
|
+
- bin/maruku
|
|
73
|
+
- bin/marutex
|
|
75
74
|
test_files: []
|
|
76
|
-
|
|
77
75
|
rdoc_options: []
|
|
78
|
-
|
|
79
76
|
extra_rdoc_files: []
|
|
80
|
-
|
|
81
77
|
executables:
|
|
82
|
-
- maruku
|
|
83
|
-
- marutex
|
|
78
|
+
- maruku
|
|
79
|
+
- marutex
|
|
84
80
|
extensions: []
|
|
85
|
-
|
|
86
81
|
requirements: []
|
|
87
|
-
|
|
88
82
|
dependencies:
|
|
89
|
-
- !ruby/object:Gem::Dependency
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: syntax
|
|
85
|
+
version_requirement:
|
|
86
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
-
|
|
89
|
+
- ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: 1.0.0
|
|
92
|
+
version:
|