mok-parser 0.3.2 → 0.3.3
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.
- checksums.yaml +4 -4
- data/History.rdoc +6 -0
- data/RELEASE +1 -1
- data/VERSION +1 -1
- data/lib/mokblockparser.ry +14 -8
- data/lib/mokblockparser.tab.rb +14 -8
- data/lib/mokinlineparser.ry +9 -2
- data/lib/mokinlineparser.tab.rb +14 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de67b5512a58b3922c5cff99c8ef6684992170b4
|
4
|
+
data.tar.gz: 08559b49ab0865d3a5707f9825c191ef89f6b692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59c011913a4536fcfb66b784ce6033976d54f90682f5bdbad43aae2eb9f8e3c32a6c884546ffc05447bce332bed026a41d5e0031d5b083d2de188cf2641fbccf
|
7
|
+
data.tar.gz: fe0e0948eb27556e17abb0f55e95634dfd790651b0b48fcacb801f068f09b3e6f822e91190708d961d866bd08ef1e1ca96d767c2482f89cc59aac24996f799ed
|
data/History.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.3.3 2013-12-31
|
2
|
+
* new: インラインのパーサーエラー時に行数と内容を表示
|
3
|
+
* new: ドキュメント内プログラムのスイッチオプション(@options[:erb])を追加
|
4
|
+
* fix: ドキュメントが空の時に Racc::ParseError の例外が発生しないように修正
|
5
|
+
* fix: 変数定義((@a=b@))内でオプション設定が必要な機能(リファレンスの.%など)が動いていなかった問題を修正
|
6
|
+
|
1
7
|
== 0.3.2 2013-12-20
|
2
8
|
* new: 部分テンプレート(partial)機能を試験的に追加
|
3
9
|
* change: _base_directory オプションを *_directory に変更
|
data/RELEASE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2013-12-
|
1
|
+
2013-12-31
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/mokblockparser.ry
CHANGED
@@ -47,7 +47,7 @@ class BlockParser
|
|
47
47
|
@index[:head] << {:title => title, :level => level, :index => @head_index.to_s}
|
48
48
|
HeadLine.new([level, title, @index[:head].size, @head_index.to_s]) }
|
49
49
|
# ----- paragraph
|
50
|
-
paragraph : plain_texts { Paragraph.new @inline_parser.parse(val) }
|
50
|
+
paragraph : plain_texts { Paragraph.new @inline_parser.parse(val, @no) }
|
51
51
|
|
52
52
|
plain_texts : PLAIN { val[0] }
|
53
53
|
| plain_texts PLAIN { val[0] + val[1] }
|
@@ -57,7 +57,7 @@ class BlockParser
|
|
57
57
|
if val[1].nil?
|
58
58
|
lines = [Plain.new("")]
|
59
59
|
else
|
60
|
-
lines = @inline_parser.parse(val[1])
|
60
|
+
lines = @inline_parser.parse(val[1], @no)
|
61
61
|
end
|
62
62
|
Desc.new([val[0], lines])
|
63
63
|
}
|
@@ -76,7 +76,7 @@ class BlockParser
|
|
76
76
|
|
77
77
|
# ----- preformat end
|
78
78
|
# ----- quote
|
79
|
-
quote_block : quotes { qu = val[0].strip ; Quote.new(@inline_parser.parse(qu)) unless qu.empty? }
|
79
|
+
quote_block : quotes { qu = val[0].strip ; Quote.new(@inline_parser.parse(qu, @no)) unless qu.empty? }
|
80
80
|
|
81
81
|
quotes : QUOTE { val[0] }
|
82
82
|
| quotes QUOTE { val[0] + val[1] }
|
@@ -91,8 +91,8 @@ class BlockParser
|
|
91
91
|
|
92
92
|
itemlist_indent_blocks : INDENT itemlist_blocks DEDENT { val }
|
93
93
|
|
94
|
-
itemlists : itemlistitems {[PlainTextBlock.new(@inline_parser.parse(val[0]))]}
|
95
|
-
| itemlists itemlistitems { val[0] << PlainTextBlock.new(@inline_parser.parse(val[1])) }
|
94
|
+
itemlists : itemlistitems {[PlainTextBlock.new(@inline_parser.parse(val[0], @no))]}
|
95
|
+
| itemlists itemlistitems { val[0] << PlainTextBlock.new(@inline_parser.parse(val[1],@no)) }
|
96
96
|
|
97
97
|
itemlistitems : ITEMLIST { val[0] }
|
98
98
|
| ITEMLIST itemlist_continues { val[0] + val[1] }
|
@@ -110,8 +110,8 @@ class BlockParser
|
|
110
110
|
|
111
111
|
numlist_indent_blocks : INDENT numlist_blocks DEDENT { val }
|
112
112
|
|
113
|
-
numlists : NUMLIST { [PlainTextBlock.new(@inline_parser.parse(val[0]))] }
|
114
|
-
| numlists NUMLIST { val[0] << PlainTextBlock.new(@inline_parser.parse(val[1])) }
|
113
|
+
numlists : NUMLIST { [PlainTextBlock.new(@inline_parser.parse(val[0],@no))] }
|
114
|
+
| numlists NUMLIST { val[0] << PlainTextBlock.new(@inline_parser.parse(val[1],@no)) }
|
115
115
|
|
116
116
|
# ----- numlist end
|
117
117
|
|
@@ -158,8 +158,14 @@ attr_reader :metadata, :inline_index, :index
|
|
158
158
|
|
159
159
|
def parse(src)
|
160
160
|
@no = 0
|
161
|
+
|
162
|
+
# srcが空の時の対応
|
163
|
+
src = ["# No Document"] if src.size == 0
|
164
|
+
|
161
165
|
# srcをerbで処理
|
162
|
-
|
166
|
+
if @options[:erb]
|
167
|
+
src = ERB.new(src.join,4).result(binding.taint).split("\n").map {|s| "#{s}\n"}
|
168
|
+
end
|
163
169
|
|
164
170
|
# 部分テンプレート(partial)
|
165
171
|
src = insert_partial(src)
|
data/lib/mokblockparser.tab.rb
CHANGED
@@ -49,8 +49,14 @@ attr_reader :metadata, :inline_index, :index
|
|
49
49
|
|
50
50
|
def parse(src)
|
51
51
|
@no = 0
|
52
|
+
|
53
|
+
# srcが空の時の対応
|
54
|
+
src = ["# No Document"] if src.size == 0
|
55
|
+
|
52
56
|
# srcをerbで処理
|
53
|
-
|
57
|
+
if @options[:erb]
|
58
|
+
src = ERB.new(src.join,4).result(binding.taint).split("\n").map {|s| "#{s}\n"}
|
59
|
+
end
|
54
60
|
|
55
61
|
# 部分テンプレート(partial)
|
56
62
|
src = insert_partial(src)
|
@@ -568,7 +574,7 @@ module_eval(<<'.,.,', 'mokblockparser.ry', 36)
|
|
568
574
|
|
569
575
|
module_eval(<<'.,.,', 'mokblockparser.ry', 49)
|
570
576
|
def _reduce_16(val, _values)
|
571
|
-
Paragraph.new @inline_parser.parse(val)
|
577
|
+
Paragraph.new @inline_parser.parse(val, @no)
|
572
578
|
end
|
573
579
|
.,.,
|
574
580
|
|
@@ -589,7 +595,7 @@ module_eval(<<'.,.,', 'mokblockparser.ry', 56)
|
|
589
595
|
if val[1].nil?
|
590
596
|
lines = [Plain.new("")]
|
591
597
|
else
|
592
|
-
lines = @inline_parser.parse(val[1])
|
598
|
+
lines = @inline_parser.parse(val[1], @no)
|
593
599
|
end
|
594
600
|
Desc.new([val[0], lines])
|
595
601
|
|
@@ -630,7 +636,7 @@ module_eval(<<'.,.,', 'mokblockparser.ry', 74)
|
|
630
636
|
|
631
637
|
module_eval(<<'.,.,', 'mokblockparser.ry', 78)
|
632
638
|
def _reduce_26(val, _values)
|
633
|
-
qu = val[0].strip ; Quote.new(@inline_parser.parse(qu)) unless qu.empty?
|
639
|
+
qu = val[0].strip ; Quote.new(@inline_parser.parse(qu, @no)) unless qu.empty?
|
634
640
|
end
|
635
641
|
.,.,
|
636
642
|
|
@@ -678,13 +684,13 @@ module_eval(<<'.,.,', 'mokblockparser.ry', 91)
|
|
678
684
|
|
679
685
|
module_eval(<<'.,.,', 'mokblockparser.ry', 93)
|
680
686
|
def _reduce_34(val, _values)
|
681
|
-
[PlainTextBlock.new(@inline_parser.parse(val[0]))]
|
687
|
+
[PlainTextBlock.new(@inline_parser.parse(val[0], @no))]
|
682
688
|
end
|
683
689
|
.,.,
|
684
690
|
|
685
691
|
module_eval(<<'.,.,', 'mokblockparser.ry', 94)
|
686
692
|
def _reduce_35(val, _values)
|
687
|
-
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1]))
|
693
|
+
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1],@no))
|
688
694
|
end
|
689
695
|
.,.,
|
690
696
|
|
@@ -744,13 +750,13 @@ module_eval(<<'.,.,', 'mokblockparser.ry', 110)
|
|
744
750
|
|
745
751
|
module_eval(<<'.,.,', 'mokblockparser.ry', 112)
|
746
752
|
def _reduce_45(val, _values)
|
747
|
-
[PlainTextBlock.new(@inline_parser.parse(val[0]))]
|
753
|
+
[PlainTextBlock.new(@inline_parser.parse(val[0],@no))]
|
748
754
|
end
|
749
755
|
.,.,
|
750
756
|
|
751
757
|
module_eval(<<'.,.,', 'mokblockparser.ry', 113)
|
752
758
|
def _reduce_46(val, _values)
|
753
|
-
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1]))
|
759
|
+
val[0] << PlainTextBlock.new(@inline_parser.parse(val[1],@no))
|
754
760
|
end
|
755
761
|
.,.,
|
756
762
|
|
data/lib/mokinlineparser.ry
CHANGED
@@ -164,7 +164,7 @@ class InlineParser
|
|
164
164
|
@variables[base] = text unless text.nil?
|
165
165
|
value = @variables[base]
|
166
166
|
unless value.nil?
|
167
|
-
parser = InlineParser.new
|
167
|
+
parser = InlineParser.new(@options)
|
168
168
|
value = parser.parse(value).map do |n| n.apply end
|
169
169
|
else # 変数が未定義
|
170
170
|
value = base
|
@@ -357,13 +357,20 @@ other_re_mode = Regexp::MULTILINE
|
|
357
357
|
OTHER_RE = Regexp.new(
|
358
358
|
"\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|#{Regexp.quote(ITALIC_OPEN)}|#{Regexp.quote(ITALIC_CLOSE)}|#{Regexp.quote(STRIKE_OPEN)}|#{Regexp.quote(STRIKE_CLOSE)}|#{Regexp.quote(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|#{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(VARIABLE_OPEN)}|#{Regexp.quote(VARIABLE_CLOSE)}|#{Regexp.quote(MEDIA_OPEN)}|#{Regexp.quote(MEDIA_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_LINK_OPEN)}|#{Regexp.quote(LABEL_LINK_CLOSE)}|#{Regexp.quote(LABEL_HTML_OPEN)}|#{Regexp.quote(LABEL_HTML_CLOSE)}|#{Regexp.quote(REFERENCE_OPEN)}|#{Regexp.quote(REFERENCE_CLOSE)}|#{Regexp.quote(REFERENCE_HTML_OPEN)}|#{Regexp.quote(REFERENCE_HTML_CLOSE)}|#{Regexp.quote(MANUEDO_OPEN)}|#{Regexp.quote(MANUEDO_CLOSE)}|#{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)})", other_re_mode)
|
359
359
|
|
360
|
-
def
|
360
|
+
def on_error(token_id, value, stack)
|
361
|
+
raise Racc::ParseError,
|
362
|
+
"mokinlinepaser: line #{@lineno} in document: syntax error on '#{stack[0][0].contents}#{stack[1]}'"
|
363
|
+
end
|
364
|
+
|
365
|
+
def parse(src, lineno = "?")
|
361
366
|
@src = StringScanner.new(Array(src).join)
|
367
|
+
@lineno = lineno
|
362
368
|
@pre = ""
|
363
369
|
@@yydebug = false
|
364
370
|
@view_token_type = false
|
365
371
|
do_parse
|
366
372
|
end
|
373
|
+
|
367
374
|
def initialize(options = {})
|
368
375
|
@options = options
|
369
376
|
@variables = options[:variables]
|
data/lib/mokinlineparser.tab.rb
CHANGED
@@ -107,12 +107,23 @@ other_re_mode = Regexp::MULTILINE
|
|
107
107
|
OTHER_RE = Regexp.new(
|
108
108
|
"\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|#{Regexp.quote(ITALIC_OPEN)}|#{Regexp.quote(ITALIC_CLOSE)}|#{Regexp.quote(STRIKE_OPEN)}|#{Regexp.quote(STRIKE_CLOSE)}|#{Regexp.quote(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|#{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|#{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|#{Regexp.quote(RUBY_OPEN)}|#{Regexp.quote(RUBY_CLOSE)}|#{Regexp.quote(VARIABLE_OPEN)}|#{Regexp.quote(VARIABLE_CLOSE)}|#{Regexp.quote(MEDIA_OPEN)}|#{Regexp.quote(MEDIA_CLOSE)}|#{Regexp.quote(LABEL_OPEN)}|#{Regexp.quote(LABEL_CLOSE)}|#{Regexp.quote(LABEL_LINK_OPEN)}|#{Regexp.quote(LABEL_LINK_CLOSE)}|#{Regexp.quote(LABEL_HTML_OPEN)}|#{Regexp.quote(LABEL_HTML_CLOSE)}|#{Regexp.quote(REFERENCE_OPEN)}|#{Regexp.quote(REFERENCE_CLOSE)}|#{Regexp.quote(REFERENCE_HTML_OPEN)}|#{Regexp.quote(REFERENCE_HTML_CLOSE)}|#{Regexp.quote(MANUEDO_OPEN)}|#{Regexp.quote(MANUEDO_CLOSE)}|#{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)})", other_re_mode)
|
109
109
|
|
110
|
-
def
|
110
|
+
def on_error(token_id, value, stack)
|
111
|
+
|
112
|
+
raise Racc::ParseError,
|
113
|
+
"mokinlinepaser: line #{@lineno} in document: syntax error on '#{stack[0][0].contents}#{stack[1]}'"
|
114
|
+
end
|
115
|
+
|
116
|
+
def parse(src, lineno = "?")
|
111
117
|
@src = StringScanner.new(Array(src).join)
|
118
|
+
@lineno = lineno
|
112
119
|
@pre = ""
|
113
120
|
@@yydebug = false
|
114
121
|
@view_token_type = false
|
115
|
-
|
122
|
+
# begin
|
123
|
+
do_parse
|
124
|
+
# rescue Racc::ParseError
|
125
|
+
# puts "Racc::ParseError desu"
|
126
|
+
# end
|
116
127
|
end
|
117
128
|
def initialize(options = {})
|
118
129
|
@options = options
|
@@ -1068,7 +1079,7 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 161)
|
|
1068
1079
|
@variables[base] = text unless text.nil?
|
1069
1080
|
value = @variables[base]
|
1070
1081
|
unless value.nil?
|
1071
|
-
parser = InlineParser.new
|
1082
|
+
parser = InlineParser.new(@options)
|
1072
1083
|
value = parser.parse(value).map do |n| n.apply end
|
1073
1084
|
else # 変数が未定義
|
1074
1085
|
value = base
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mok-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- garin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|