mok-parser 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f54fd74fc573d9965c6442b8c4109897cc107cbd
4
- data.tar.gz: fdc84713c6551e8f8e027fb0ed0b0c90cb35d4b9
3
+ metadata.gz: 979f9c3bab2b80999ba5c86cc58cd43b7f5007e3
4
+ data.tar.gz: 0f4e4a31757eb142a6907d4bc803ccbaf0d6f177
5
5
  SHA512:
6
- metadata.gz: e450134c735403f2ab3cd44be2c8434cff2d444a1ee0b29e31167427bf1d53fac9ad81267501eee3e1d4172023f48b393db02b332de6108508fa46cd57f426ee
7
- data.tar.gz: b8e2827420a4ddd18ed24294eb86be01a3b0d72cd1106aa5ad644acbf4728190e8fb0cca1f189d7efd00ba3becf7aee6d17e272718a661cc9c34d927a458515b
6
+ metadata.gz: ce4ba3be3ad44a4ebf2e9d03ab1c618d32c8c6f1058c959b4fde44b9ef27d3473a2d6b885a4353cc1cc913f73e317206d7fbf67f528f51a7d7ee1b172c4556fb
7
+ data.tar.gz: 511c408a35309c8938fd30e8272a15529e3a0c3417ea81a8b5bf116381584bafe8f050ecf8157ece11a6c5e422b1fe122c551952acd57c79adc24a182f7c3f23
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.3.1 2013-12-14
2
+ * new: Referenceエレメントにreference_base_directoryオプションを追加
3
+ * change: Mediaエレメントの media_directory オプションを media_base_directory
4
+ * パスが ルート・カレントディレクトリだった時に *_base_directory を無視するように変更
5
+
1
6
  == 0.3.0 2013-12-12
2
7
  * プロジェクト名を raf-parser から mok-parser に変更
3
8
 
data/RELEASE CHANGED
@@ -1 +1 @@
1
- 2013-12-12
1
+ 2013-12-14
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -72,10 +72,7 @@ class InlineParser
72
72
 
73
73
  media_strings : media_strings media_string { val.join }
74
74
  | media_string {
75
- unless @options[:media_directory].nil? || @options[:media_directory].empty?
76
- val[0] = File.join(@options[:media_directory],val[0]) unless val[0] =~ /^.*:\/\/.*/
77
- end
78
- val[0]
75
+ mok_link_path(val[0], @options[:media_base_directory])
79
76
  }
80
77
  media : MEDIA_OPEN media_strings MEDIA_CLOSE {
81
78
  mime = MimeMagic.by_extension(val[1].split(".").last)
@@ -222,6 +219,7 @@ class InlineParser
222
219
  uri.slice!(-2,2)
223
220
  uri = "#{uri}#{@options[:reference_extension]}"
224
221
  end
222
+ uri = mok_link_path(uri, @options[:reference_base_directory])
225
223
  Reference.new([title, uri])
226
224
  }
227
225
  # --- reference : end
@@ -515,6 +513,15 @@ def next_token
515
513
  end
516
514
  end
517
515
 
516
+ # reference, media エレメントのリンク用のパスを生成する
517
+ def mok_link_path(path, base_dir = nil)
518
+ path = path.strip
519
+ return path if base_dir.nil? or base_dir.empty? # non base_dir
520
+ return path if path =~ /^.*:\/\/.*/ # uri
521
+ return path if path =~ /^\/.*/ or path =~ /^\.\/.*/ # root or currentdirectory
522
+ File.join(base_dir,path)
523
+ end
524
+
518
525
  ---- header
519
526
  require "parserutility"
520
527
  require 'strscan'
@@ -523,6 +530,7 @@ require 'erb'
523
530
  require 'mokelement'
524
531
 
525
532
  module Mok
533
+
526
534
  ---- footer
527
535
  if __FILE__ == $0
528
536
  mok = InlineParser.new
@@ -13,9 +13,10 @@ require 'erb'
13
13
  require 'mokelement'
14
14
 
15
15
  module Mok
16
+
16
17
  class InlineParser < Racc::Parser
17
18
 
18
- module_eval(<<'...end mokinlineparser.ry/module_eval...', 'mokinlineparser.ry', 272)
19
+ module_eval(<<'...end mokinlineparser.ry/module_eval...', 'mokinlineparser.ry', 270)
19
20
  include ParserUtility
20
21
 
21
22
  EM_OPEN = '((*'
@@ -262,6 +263,15 @@ def next_token
262
263
  end
263
264
  end
264
265
 
266
+ # reference, media エレメントのリンク用のパスを生成する
267
+ def mok_link_path(path, base_dir = nil)
268
+ path = path.strip
269
+ return path if base_dir.nil? or base_dir.empty? # non base_dir
270
+ return path if path =~ /^.*:\/\/.*/ # uri
271
+ return path if path =~ /^\/.*/ or path =~ /^\.\/.*/ # root or currentdirectory
272
+ File.join(base_dir,path)
273
+ end
274
+
265
275
  ...end mokinlineparser.ry/module_eval...
266
276
  ##### State transition tables begin ###
267
277
 
@@ -888,15 +898,12 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 72)
888
898
 
889
899
  module_eval(<<'.,.,', 'mokinlineparser.ry', 74)
890
900
  def _reduce_55(val, _values)
891
- unless @options[:media_directory].nil? || @options[:media_directory].empty?
892
- val[0] = File.join(@options[:media_directory],val[0]) unless val[0] =~ /^.*:\/\/.*/
893
- end
894
- val[0]
901
+ mok_link_path(val[0], @options[:media_base_directory])
895
902
 
896
903
  end
897
904
  .,.,
898
905
 
899
- module_eval(<<'.,.,', 'mokinlineparser.ry', 80)
906
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 77)
900
907
  def _reduce_56(val, _values)
901
908
  mime = MimeMagic.by_extension(val[1].split(".").last)
902
909
  unless mime.nil?
@@ -961,19 +968,19 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 80)
961
968
 
962
969
  # reduce 82 omitted
963
970
 
964
- module_eval(<<'.,.,', 'mokinlineparser.ry', 118)
971
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 115)
965
972
  def _reduce_83(val, _values)
966
973
  val.join
967
974
  end
968
975
  .,.,
969
976
 
970
- module_eval(<<'.,.,', 'mokinlineparser.ry', 119)
977
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 116)
971
978
  def _reduce_84(val, _values)
972
979
  val[0]
973
980
  end
974
981
  .,.,
975
982
 
976
- module_eval(<<'.,.,', 'mokinlineparser.ry', 122)
983
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 119)
977
984
  def _reduce_85(val, _values)
978
985
  base, text = val[1].split("|",2)
979
986
  text ||= base
@@ -1040,19 +1047,19 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 122)
1040
1047
 
1041
1048
  # reduce 113 omitted
1042
1049
 
1043
- module_eval(<<'.,.,', 'mokinlineparser.ry', 160)
1050
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 157)
1044
1051
  def _reduce_114(val, _values)
1045
1052
  val.join
1046
1053
  end
1047
1054
  .,.,
1048
1055
 
1049
- module_eval(<<'.,.,', 'mokinlineparser.ry', 161)
1056
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 158)
1050
1057
  def _reduce_115(val, _values)
1051
1058
  val[0]
1052
1059
  end
1053
1060
  .,.,
1054
1061
 
1055
- module_eval(<<'.,.,', 'mokinlineparser.ry', 164)
1062
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 161)
1056
1063
  def _reduce_116(val, _values)
1057
1064
  base, text = val[1].split("=",2)
1058
1065
  @variables ||= {}
@@ -1069,31 +1076,31 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 164)
1069
1076
  end
1070
1077
  .,.,
1071
1078
 
1072
- module_eval(<<'.,.,', 'mokinlineparser.ry', 178)
1079
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 175)
1073
1080
  def _reduce_117(val, _values)
1074
1081
  Manuedo.new(val[1])
1075
1082
  end
1076
1083
  .,.,
1077
1084
 
1078
- module_eval(<<'.,.,', 'mokinlineparser.ry', 183)
1085
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 180)
1079
1086
  def _reduce_118(val, _values)
1080
1087
  val[0]
1081
1088
  end
1082
1089
  .,.,
1083
1090
 
1084
- module_eval(<<'.,.,', 'mokinlineparser.ry', 186)
1091
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 183)
1085
1092
  def _reduce_119(val, _values)
1086
1093
  val.join
1087
1094
  end
1088
1095
  .,.,
1089
1096
 
1090
- module_eval(<<'.,.,', 'mokinlineparser.ry', 187)
1097
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 184)
1091
1098
  def _reduce_120(val, _values)
1092
1099
  val[0]
1093
1100
  end
1094
1101
  .,.,
1095
1102
 
1096
- module_eval(<<'.,.,', 'mokinlineparser.ry', 190)
1103
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 187)
1097
1104
  def _reduce_121(val, _values)
1098
1105
  label, title = val[1].split("|",2)
1099
1106
  title ||= label
@@ -1104,25 +1111,25 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 190)
1104
1111
  end
1105
1112
  .,.,
1106
1113
 
1107
- module_eval(<<'.,.,', 'mokinlineparser.ry', 199)
1114
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 196)
1108
1115
  def _reduce_122(val, _values)
1109
1116
  val[0]
1110
1117
  end
1111
1118
  .,.,
1112
1119
 
1113
- module_eval(<<'.,.,', 'mokinlineparser.ry', 201)
1120
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 198)
1114
1121
  def _reduce_123(val, _values)
1115
1122
  val.join
1116
1123
  end
1117
1124
  .,.,
1118
1125
 
1119
- module_eval(<<'.,.,', 'mokinlineparser.ry', 202)
1126
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 199)
1120
1127
  def _reduce_124(val, _values)
1121
1128
  val[0]
1122
1129
  end
1123
1130
  .,.,
1124
1131
 
1125
- module_eval(<<'.,.,', 'mokinlineparser.ry', 205)
1132
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 202)
1126
1133
  def _reduce_125(val, _values)
1127
1134
  label, title = val[1].split("|",2)
1128
1135
  title ||= label
@@ -1131,25 +1138,25 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 205)
1131
1138
  end
1132
1139
  .,.,
1133
1140
 
1134
- module_eval(<<'.,.,', 'mokinlineparser.ry', 212)
1141
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 209)
1135
1142
  def _reduce_126(val, _values)
1136
1143
  val[0]
1137
1144
  end
1138
1145
  .,.,
1139
1146
 
1140
- module_eval(<<'.,.,', 'mokinlineparser.ry', 214)
1147
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 211)
1141
1148
  def _reduce_127(val, _values)
1142
1149
  val.join
1143
1150
  end
1144
1151
  .,.,
1145
1152
 
1146
- module_eval(<<'.,.,', 'mokinlineparser.ry', 215)
1153
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 212)
1147
1154
  def _reduce_128(val, _values)
1148
1155
  val[0]
1149
1156
  end
1150
1157
  .,.,
1151
1158
 
1152
- module_eval(<<'.,.,', 'mokinlineparser.ry', 218)
1159
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 215)
1153
1160
  def _reduce_129(val, _values)
1154
1161
  title, uri = val[1].split("|",2)
1155
1162
  uri ||= title
@@ -1157,6 +1164,7 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 218)
1157
1164
  uri.slice!(-2,2)
1158
1165
  uri = "#{uri}#{@options[:reference_extension]}"
1159
1166
  end
1167
+ uri = mok_link_path(uri, @options[:reference_base_directory])
1160
1168
  Reference.new([title, uri])
1161
1169
 
1162
1170
  end
@@ -1220,31 +1228,31 @@ module_eval(<<'.,.,', 'mokinlineparser.ry', 218)
1220
1228
 
1221
1229
  # reduce 158 omitted
1222
1230
 
1223
- module_eval(<<'.,.,', 'mokinlineparser.ry', 258)
1231
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 256)
1224
1232
  def _reduce_159(val, _values)
1225
1233
  val
1226
1234
  end
1227
1235
  .,.,
1228
1236
 
1229
- module_eval(<<'.,.,', 'mokinlineparser.ry', 260)
1237
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 258)
1230
1238
  def _reduce_160(val, _values)
1231
1239
  Verb.new(val[1])
1232
1240
  end
1233
1241
  .,.,
1234
1242
 
1235
- module_eval(<<'.,.,', 'mokinlineparser.ry', 264)
1243
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 262)
1236
1244
  def _reduce_161(val, _values)
1237
1245
  Plain.new(val[0])
1238
1246
  end
1239
1247
  .,.,
1240
1248
 
1241
- module_eval(<<'.,.,', 'mokinlineparser.ry', 265)
1249
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 263)
1242
1250
  def _reduce_162(val, _values)
1243
1251
  Plain.new([val[0].contents, val[1]])
1244
1252
  end
1245
1253
  .,.,
1246
1254
 
1247
- module_eval(<<'.,.,', 'mokinlineparser.ry', 267)
1255
+ module_eval(<<'.,.,', 'mokinlineparser.ry', 265)
1248
1256
  def _reduce_163(val, _values)
1249
1257
  val[0]
1250
1258
  end
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.0
4
+ version: 0.3.1
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-12 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler