arti_mark 0.0.1.beta3 → 0.0.1.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/arti_mark/base_parser.rb +1 -1
- data/lib/arti_mark/block_image_parser.rb +8 -5
- data/lib/arti_mark/command_lexer.rb +44 -19
- data/lib/arti_mark/common_block_parser.rb +3 -3
- data/lib/arti_mark/head_parser.rb +5 -3
- data/lib/arti_mark/list_parser.rb +1 -1
- data/lib/arti_mark/syntax.rb +26 -13
- data/lib/arti_mark/version.rb +1 -1
- data/lib/arti_mark.rb +5 -1
- data/spec/arti_mark_spec.rb +91 -0
- metadata +7 -14
- data/lib/arti_mark/head_parser_flymake.rb +0 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abd2001b34dc838a27ba1c9f1e188fde512e2468
|
4
|
+
data.tar.gz: 3d683b3d4c7e09efd3414ab6c62503d09d804503
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a01c7e24864ca6fa710ca1b22e13c3c8e00f2ab13d2aa0036aa268be4501d63c82266d5a7192dc7420750816495417b46ca9d8090037c817711558037a592d14
|
7
|
+
data.tar.gz: 51e4d4bef90306fb68f879fcaf8db6305bc54a6b52a402f50b62cf4db2628d963352a9bfeac09a75e14e8973014152aab239dd53812fbfd88a09dc648f110976
|
@@ -13,12 +13,15 @@ module ArtiMark
|
|
13
13
|
lines.shift
|
14
14
|
lexed[:cls] << 'img-wrap' if lexed[:cls].size == 0
|
15
15
|
src = lexed[:params][0].strip
|
16
|
-
alt = lexed[:params][1].strip
|
16
|
+
alt = lexed[:params][1].strip if !lexed[:params][1].nil?
|
17
17
|
caption = lexed[:text].strip
|
18
|
-
|
19
|
-
|
20
|
-
r << "<
|
18
|
+
caption_before = lexed[:named_params][:caption_before]
|
19
|
+
|
20
|
+
r << "<div#{ids_string(lexed[:ids])}#{class_string(lexed[:cls])}>"
|
21
|
+
r << "<p>#{caption}</p>" if !caption.nil? && caption.size > 0 && caption_before
|
22
|
+
r << "<img src='#{src}' alt='#{alt}' />"
|
23
|
+
r << "<p>#{caption}</p>" if !caption.nil? && caption.size > 0 && !caption_before
|
21
24
|
r << "</div>\n"
|
22
25
|
end
|
23
26
|
end
|
24
|
-
end
|
27
|
+
end
|
@@ -8,45 +8,70 @@ module ArtiMark
|
|
8
8
|
gsub('"', """)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
if
|
11
|
+
def attr_string(the_array, attr_name)
|
12
|
+
if the_array.size == 0
|
13
13
|
''
|
14
14
|
else
|
15
|
-
"
|
15
|
+
" #{attr_name}='#{the_array.join(' ')}'"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
cls_array
|
21
|
-
|
22
|
-
|
19
|
+
def class_string(cls_array)
|
20
|
+
attr_string(cls_array, 'class')
|
21
|
+
end
|
22
|
+
|
23
|
+
def ids_string(ids_array)
|
24
|
+
attr_string(ids_array, 'id')
|
25
|
+
end
|
26
|
+
def attr_array(part, separator=".")
|
27
|
+
the_array = []
|
28
|
+
if !part.nil? && part.size > 0
|
29
|
+
the_array = part[1..-1].split(separator)
|
23
30
|
end
|
24
|
-
|
31
|
+
the_array
|
32
|
+
end
|
33
|
+
def id_array(id_part)
|
34
|
+
attr_array(id_part, '#')
|
25
35
|
end
|
26
36
|
|
27
|
-
def
|
37
|
+
def class_array(cls_part)
|
38
|
+
attr_array(cls_part, '.')
|
39
|
+
end
|
40
|
+
|
41
|
+
def param_parse(param_part)
|
28
42
|
r = []
|
43
|
+
named = {}
|
29
44
|
if !param_part.nil? && param_part.size > 0
|
30
45
|
r = param_part.split(',')
|
31
46
|
end
|
32
|
-
r
|
33
|
-
|
47
|
+
r.each {
|
48
|
+
|param|
|
49
|
+
splitted = param.split(':', 2)
|
50
|
+
if (splitted.size == 2)
|
51
|
+
named[splitted[0].strip.to_sym] = splitted[1]
|
52
|
+
end
|
53
|
+
}
|
54
|
+
return r, named
|
55
|
+
end
|
34
56
|
|
35
57
|
def lex_line_command(line)
|
36
|
-
|
37
|
-
|
58
|
+
line =~ /^([\w\*;]+?)((?:\#[A-Za-z0-9_\-]+?)*)((?:\.[A-Za-z0-9_\-]+?)*)(?:\((.+?)\))?\s*:(.*?)$/
|
59
|
+
all_params, named_params = param_parse($4)
|
60
|
+
return { :cmd => $1, :ids => id_array($2), :cls => class_array($3), :params => all_params, :named_params => named_params, :text => $5 }
|
38
61
|
end
|
39
62
|
|
40
63
|
def lex_block_command(line)
|
41
|
-
|
42
|
-
|
64
|
+
line =~ /^(\w+?)((?:\#[A-Za-z0-9_\-]+?)*)((?:\.[A-Za-z0-9_\-]+?)*)(?:\((.+?)\))?\s*(?:{(---)?)\s*$/
|
65
|
+
not_named, named = param_parse($4)
|
66
|
+
return { :cmd => $1, :ids => id_array($2), :cls => class_array($3), :params => not_named, :named_params => named, :delimiter => $5||''}
|
43
67
|
end
|
44
68
|
|
45
69
|
def replace_inline_commands(line, syntax, context)
|
46
|
-
line.gsub(/\[(\w+?)((?:\.[A-Za-z0-9_\-]+?)*)(?:\((.+?)\))?\s*{(.*?)}\]/) {
|
70
|
+
line.gsub(/\[(\w+?)((?:\#[A-Za-z0-9_\-]+?)*)((?:\.[A-Za-z0-9_\-]+?)*)(?:\((.+?)\))?\s*{(.*?)}\]/) {
|
47
71
|
|matched|
|
48
|
-
|
49
|
-
|
72
|
+
not_named, named = param_parse($4)
|
73
|
+
lexed = {:cmd => $1, :ids => id_array($2), :cls => class_array($3), :params => not_named, :named_params => named, :text => $5 }
|
74
|
+
if !lexed[:cmd].nil?
|
50
75
|
syntax.inline_handler.send(lexed[:cmd], lexed, context)
|
51
76
|
else
|
52
77
|
matched
|
@@ -55,4 +80,4 @@ module ArtiMark
|
|
55
80
|
end
|
56
81
|
|
57
82
|
end
|
58
|
-
end
|
83
|
+
end
|
@@ -13,13 +13,13 @@ module ArtiMark
|
|
13
13
|
throw 'something wrong here #{lines}' unless lexed[:cmd] =~ @command
|
14
14
|
@markup = lexed[:cmd] if @markup.nil?
|
15
15
|
r.enter_block(lexed)
|
16
|
-
process_block(lines, r, syntax, lexed[:cls], lexed[:params])
|
16
|
+
process_block(lines, r, syntax, lexed[:ids], lexed[:cls], lexed[:params])
|
17
17
|
r.exit_block(lexed)
|
18
18
|
end
|
19
19
|
|
20
|
-
def process_block(lines, r, syntax, cls_array, params)
|
20
|
+
def process_block(lines, r, syntax, ids_array, cls_array, params)
|
21
21
|
previous_pgroup , r.enable_pgroup = r.enable_pgroup , false if params.member? 'wo-pgroup'
|
22
|
-
r << "<#{@markup}#{class_string(cls_array)}>\n"
|
22
|
+
r << "<#{@markup}#{ids_string(ids_array)}#{class_string(cls_array)}>\n"
|
23
23
|
while lines.size > 0
|
24
24
|
if r.block_close? lines[0]
|
25
25
|
lines.shift
|
@@ -8,11 +8,13 @@ module ArtiMark
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def parse(lines, r, syntax)
|
11
|
-
|
11
|
+
line = escape_html lines[0]
|
12
|
+
line = replace_inline_commands(line, syntax, r)
|
13
|
+
lexed = lex_line_command(line)
|
12
14
|
raise 'HeadParser called for #{lines[0]}' unless lexed[:cmd] =~ /h([1-6])/
|
13
15
|
lines.shift
|
14
|
-
r << "<#{lexed[:cmd]}#{class_string(lexed[:cls])}>#{
|
16
|
+
r << "<#{lexed[:cmd]}#{ids_string(lexed[:ids])}#{class_string(lexed[:cls])}>#{lexed[:text].strip}</#{lexed[:cmd]}>\n"
|
15
17
|
r.toc = lexed[:text].strip if lexed[:params].member? 'in-toc'
|
16
18
|
end
|
17
19
|
end
|
18
|
-
end
|
20
|
+
end
|
@@ -10,7 +10,7 @@ module ArtiMark
|
|
10
10
|
|
11
11
|
def parse(lines, r, syntax)
|
12
12
|
lexed = lex_line_command(lines[0])
|
13
|
-
r << "<#{@blockname}#{class_string(lexed[:cls])}>\n"
|
13
|
+
r << "<#{@blockname}#{ids_string(lexed[:ids])}#{class_string(lexed[:cls])}>\n"
|
14
14
|
process_block(lines, r, syntax)
|
15
15
|
r << "</#{@blockname}>\n"
|
16
16
|
end
|
data/lib/arti_mark/syntax.rb
CHANGED
@@ -30,10 +30,9 @@ module ArtiMark
|
|
30
30
|
parser.method(:parse)
|
31
31
|
]
|
32
32
|
}
|
33
|
-
|
34
33
|
def @inline_handler.l(lexed, context)
|
35
34
|
ref = lexed[:params][0].strip
|
36
|
-
"<a#{class_string(lexed[:cls])} href='#{ref}'>#{lexed[:text].strip}</a>"
|
35
|
+
"<a#{ids_string(lexed[:ids])}#{class_string(lexed[:cls])} href='#{ref}'>#{lexed[:text].strip}</a>"
|
37
36
|
end
|
38
37
|
|
39
38
|
def @inline_handler.link(lexed, context)
|
@@ -42,38 +41,38 @@ module ArtiMark
|
|
42
41
|
|
43
42
|
def @inline_handler.s(lexed, context)
|
44
43
|
cls, text = lexed[:cls], lexed[:text]
|
45
|
-
"<span#{class_string(cls)}>#{text.strip}</
|
44
|
+
"<span#{ids_string(lexed[:ids])}#{class_string(cls)}>#{text.strip}</span>"
|
46
45
|
end
|
47
46
|
|
48
47
|
def @inline_handler.img(lexed, context)
|
49
48
|
cls, param, text = lexed[:cls], lexed[:params], lexed[:text]
|
50
|
-
"<img#{class_string(cls)} src='#{text.strip}' alt='#{param.join(' ')}' />"
|
49
|
+
"<img#{ids_string(lexed[:ids])}#{class_string(cls)} src='#{text.strip}' alt='#{param.join(' ')}' />"
|
51
50
|
end
|
52
51
|
|
53
52
|
def @inline_handler.ruby(lexed, context)
|
54
53
|
cls, param, text = lexed[:cls], lexed[:params], lexed[:text]
|
55
|
-
"<ruby#{class_string(cls)}>#{text.strip}<rp>(</rp><rt>#{param.join}</rt><rp>)</rp></ruby>"
|
54
|
+
"<ruby#{ids_string(lexed[:ids])}#{class_string(cls)}>#{text.strip}<rp>(</rp><rt>#{param.join}</rt><rp>)</rp></ruby>"
|
56
55
|
end
|
57
56
|
|
58
57
|
def @inline_handler.tcy(lexed, context)
|
59
58
|
cls, text = lexed[:cls], lexed[:text]
|
60
59
|
cls << 'tcy'
|
61
|
-
"<span#{class_string(cls)}>#{text.strip}</span>"
|
60
|
+
"<span#{ids_string(lexed[:ids])}#{class_string(cls)}>#{text.strip}</span>"
|
62
61
|
end
|
63
62
|
|
64
63
|
# universal inline command handler
|
65
64
|
def @inline_handler.method_missing(cmd, *args)
|
66
|
-
cls, text = args[0][:cls], args[0][:text]
|
67
|
-
"<#{cmd}#{class_string(cls)}>#{text.strip}</#{cmd}>"
|
65
|
+
ids, cls, text = args[0][:ids], args[0][:cls], args[0][:text]
|
66
|
+
"<#{cmd}#{ids_string(ids)}#{class_string(cls)}>#{text.strip}</#{cmd}>"
|
68
67
|
end
|
69
68
|
|
70
69
|
def @linecommand_handler.p(lexed, context)
|
71
70
|
cls, text = lexed[:cls], lexed[:text]
|
72
|
-
"<p#{class_string(cls)}>#{text.strip}</p>\n"
|
71
|
+
"<p#{ids_string(lexed[:ids])}#{class_string(cls)}>#{text.strip}</p>\n"
|
73
72
|
end
|
74
73
|
|
75
74
|
def @linecommand_handler.stylesheets(lexed, context)
|
76
|
-
context.stylesheets =
|
75
|
+
context.stylesheets = lexed[:text].split(',').map {|s|
|
77
76
|
s.strip!
|
78
77
|
if s =~ /^(.+?\.css):\((.+?)\)$/
|
79
78
|
[$1, $2]
|
@@ -96,10 +95,8 @@ module ArtiMark
|
|
96
95
|
|
97
96
|
#univarsal line command handler
|
98
97
|
def @linecommand_handler.method_missing(cmd, *args)
|
99
|
-
"<#{cmd}#{class_string(args[0][:cls])}>#{args[0][:text].strip}</#{cmd}>\n"
|
98
|
+
"<#{cmd}#{ids_string(args[0][:ids])}#{class_string(args[0][:cls])}>#{args[0][:text].strip}</#{cmd}>\n"
|
100
99
|
end
|
101
|
-
|
102
|
-
|
103
100
|
end
|
104
101
|
|
105
102
|
def determine_parser(lines, opt = {})
|
@@ -117,6 +114,22 @@ module ArtiMark
|
|
117
114
|
end
|
118
115
|
end
|
119
116
|
|
117
|
+
def append_parser(parser)
|
118
|
+
if parser.respond_to?(:accept?) && parser.respond_to?(:parse)
|
119
|
+
@block_parsers << [
|
120
|
+
parser.method(:accept?),
|
121
|
+
parser.method(:parse)
|
122
|
+
]
|
123
|
+
elsif parser[:accept?] && parser[:parse]
|
124
|
+
@block_parsers << [
|
125
|
+
parser[:accept?],
|
126
|
+
parser[:parse]
|
127
|
+
]
|
128
|
+
else
|
129
|
+
raise 'parser should define accept? and parse' if !(parser.respond_to?(:accept?) && parser.respond_to?(:parse))
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
120
133
|
def default_parser
|
121
134
|
ParagraphParser.instance.method(:parse)
|
122
135
|
end
|
data/lib/arti_mark/version.rb
CHANGED
data/lib/arti_mark.rb
CHANGED
@@ -25,13 +25,17 @@ module ArtiMark
|
|
25
25
|
@syntax = Syntax.new
|
26
26
|
@preprocessors = [
|
27
27
|
Proc.new { |text| text.gsub(/\r?\n(\r?\n)+/, "\n\n") },
|
28
|
-
Proc.new { |text| text.strip.gsub(/ /, ' ') } # Japanese full-width spece to
|
28
|
+
Proc.new { |text| text.strip.gsub(/ /, ' ') } # convert Japanese full-width spece to normal space
|
29
29
|
]
|
30
30
|
end
|
31
31
|
|
32
32
|
def preprocessor(&block)
|
33
33
|
@preprocessors << block
|
34
34
|
end
|
35
|
+
|
36
|
+
def parser(parser)
|
37
|
+
@syntax.append_parser(parser)
|
38
|
+
end
|
35
39
|
|
36
40
|
def convert(text)
|
37
41
|
@preprocessors.each {
|
data/spec/arti_mark_spec.rb
CHANGED
@@ -123,6 +123,18 @@ describe ArtiMark do
|
|
123
123
|
)
|
124
124
|
end
|
125
125
|
|
126
|
+
it 'should convert div with id and class' do
|
127
|
+
text = "d#thecontents.preface-one {\n h1: title.\n}"
|
128
|
+
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
129
|
+
converted = artimark.convert(text)
|
130
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
131
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
132
|
+
['div#thecontents.preface-one',
|
133
|
+
['h1', 'title.']
|
134
|
+
]
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
126
138
|
it 'should convert nested div' do
|
127
139
|
text = "d.preface {\n outer div. \n d.nested {\n nested!\n}\nouter div again.\n}"
|
128
140
|
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
@@ -222,6 +234,25 @@ describe ArtiMark do
|
|
222
234
|
)
|
223
235
|
end
|
224
236
|
|
237
|
+
it 'should handle block image with before caption' do
|
238
|
+
text = "this is normal line.\nimage(./image1.jpg, alt text, caption_before: true): caption text"
|
239
|
+
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
240
|
+
converted = artimark.convert(text)
|
241
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
242
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
243
|
+
['div.pgroup',
|
244
|
+
['p', 'this is normal line.']
|
245
|
+
]
|
246
|
+
)
|
247
|
+
expect(body.element_children[1].selector_and_children).to eq(
|
248
|
+
['div.img-wrap',
|
249
|
+
['p', 'caption text'],
|
250
|
+
["img[src='./image1.jpg'][alt='alt text']", '']
|
251
|
+
]
|
252
|
+
)
|
253
|
+
end
|
254
|
+
|
255
|
+
|
225
256
|
it 'should handle page change article' do
|
226
257
|
text = "this is start.\nnewpage(page changed):\nthis is second page.\nnewpage:\nand the third."
|
227
258
|
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
@@ -381,6 +412,14 @@ describe ArtiMark do
|
|
381
412
|
expect(toc[3]).to eq('3rd chapter')
|
382
413
|
end
|
383
414
|
|
415
|
+
it 'should convert inline command within line block' do
|
416
|
+
text = "h1: [tcy{20}]縦中横タイトル"
|
417
|
+
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
418
|
+
converted = artimark.convert(text)
|
419
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
420
|
+
expect(body.element_children[0].selector_and_children).to eq ['h1', ['span.tcy', '20'], '縦中横タイトル']
|
421
|
+
end
|
422
|
+
|
384
423
|
it 'should handle ruby' do
|
385
424
|
text = "[ruby(とんぼ){蜻蛉}]の[ruby(めがね){眼鏡}]はみずいろめがね"
|
386
425
|
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
@@ -568,6 +607,58 @@ describe ArtiMark do
|
|
568
607
|
]
|
569
608
|
)
|
570
609
|
end
|
610
|
+
it 'should handle custom block parser' do
|
611
|
+
class TheParser
|
612
|
+
include ArtiMark::BaseParser
|
613
|
+
def accept?(lines)
|
614
|
+
lex_line_command(lines[0])[:cmd] =~ /svg/
|
615
|
+
end
|
616
|
+
def parse(lines, r, syntax)
|
617
|
+
lexed = lex_line_command(lines[0])
|
618
|
+
lines.shift
|
619
|
+
src = lexed[:params][0].strip
|
620
|
+
caption = lexed[:text].strip
|
621
|
+
r << "<div><svg xmlns='http://www.w3.org/2000/svg' version='1.1' xmlns:xlink='http://www.w3.org/1999/xlink' width='100%' height='100%' viewBox='0 0 200 200' ><image xlink:href='#{src}' /><p>#{caption}</p></sgv></div>"
|
622
|
+
end
|
623
|
+
end
|
624
|
+
text="svg(img.jpg):caption"
|
625
|
+
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
626
|
+
artimark.parser(TheParser.new)
|
627
|
+
converted = artimark.convert(text)
|
628
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
629
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
630
|
+
['div',
|
631
|
+
["svg[version='1.1'][width='100%'][height='100%'][viewBox='0 0 200 200']", ["image[href='img.jpg']", ''], ['p', 'caption']]
|
632
|
+
]
|
633
|
+
)
|
634
|
+
end
|
635
|
+
it 'should handle custom block parser with named param' do
|
636
|
+
class TheParser
|
637
|
+
include ArtiMark::BaseParser
|
638
|
+
def accept?(lines)
|
639
|
+
lex_line_command(lines[0])[:cmd] =~ /svg/
|
640
|
+
end
|
641
|
+
def parse(lines, r, syntax)
|
642
|
+
lexed = lex_line_command(lines[0])
|
643
|
+
lines.shift
|
644
|
+
src = lexed[:params][0].strip
|
645
|
+
width = lexed[:named_params][:width]
|
646
|
+
height = lexed[:named_params][:height]
|
647
|
+
caption = lexed[:text].strip
|
648
|
+
r << "<div><svg xmlns='http://www.w3.org/2000/svg' version='1.1' xmlns:xlink='http://www.w3.org/1999/xlink' width='100%' height='100%' viewBox='0 0 200 200' ><image xlink:href='#{src}' width='#{width}' height='#{height}' /><p>#{caption}</p></sgv></div>"
|
649
|
+
end
|
650
|
+
end
|
651
|
+
text="svg(img.jpg, width:200, height:200):caption"
|
652
|
+
artimark = ArtiMark::Document.new(:lang => 'ja', :title => 'the document title')
|
653
|
+
artimark.parser(TheParser.new)
|
654
|
+
converted = artimark.convert(text)
|
655
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
656
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
657
|
+
['div',
|
658
|
+
["svg[version='1.1'][width='100%'][height='100%'][viewBox='0 0 200 200']", ["image[href='img.jpg'][width='200'][height='200']", ''], ['p', 'caption']]
|
659
|
+
]
|
660
|
+
)
|
661
|
+
end
|
571
662
|
end
|
572
663
|
end
|
573
664
|
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arti_mark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
5
|
-
prerelease: 6
|
4
|
+
version: 0.0.1.beta4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- KOJIMA Satoshi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: nokogiri
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -66,7 +61,6 @@ files:
|
|
66
61
|
- lib/arti_mark/definition_list_parser.rb
|
67
62
|
- lib/arti_mark/div_parser.rb
|
68
63
|
- lib/arti_mark/head_parser.rb
|
69
|
-
- lib/arti_mark/head_parser_flymake.rb
|
70
64
|
- lib/arti_mark/list_parser.rb
|
71
65
|
- lib/arti_mark/ordered_list_parser.rb
|
72
66
|
- lib/arti_mark/paragraph_parser.rb
|
@@ -82,27 +76,26 @@ files:
|
|
82
76
|
- spec/spec_helper.rb
|
83
77
|
homepage: ''
|
84
78
|
licenses: []
|
79
|
+
metadata: {}
|
85
80
|
post_install_message:
|
86
81
|
rdoc_options: []
|
87
82
|
require_paths:
|
88
83
|
- lib
|
89
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
85
|
requirements:
|
92
|
-
- -
|
86
|
+
- - '>='
|
93
87
|
- !ruby/object:Gem::Version
|
94
88
|
version: '0'
|
95
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
90
|
requirements:
|
98
|
-
- -
|
91
|
+
- - '>'
|
99
92
|
- !ruby/object:Gem::Version
|
100
93
|
version: 1.3.1
|
101
94
|
requirements: []
|
102
95
|
rubyforge_project:
|
103
|
-
rubygems_version:
|
96
|
+
rubygems_version: 2.0.2
|
104
97
|
signing_key:
|
105
|
-
specification_version:
|
98
|
+
specification_version: 4
|
106
99
|
summary: simple and customizable text markup language for EPUB
|
107
100
|
test_files:
|
108
101
|
- spec/arti_mark_spec.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#require 'singleton'
|
2
|
-
|
3
|
-
module ArtiMark
|
4
|
-
class HeadParser
|
5
|
-
include BaseParser, Singleton
|
6
|
-
def accept?(lines)
|
7
|
-
lex_line_command(lines[0])[:cmd] =~ /h[1-6]/
|
8
|
-
end
|
9
|
-
|
10
|
-
def parse(lines, r, syntax)
|
11
|
-
lexed = lex_line_command(lines[0])
|
12
|
-
raise 'HeadParser called for #{lines[0]}' unless lexed[:cmd] =~ /h([1-6])/
|
13
|
-
lines.shift
|
14
|
-
r << "<#{lexed[:cmd]}#{class_string(lexed[:cls])}>#{escape_html lexed[:text].strip}</#{lexed[:cmd]}>\n"
|
15
|
-
r.toc = lexed[:text].strip if lexed[:params].member? 'in-toc'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|