nora_mark 0.2beta3 → 0.2beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/README.md +17 -12
- data/example/nora-simple.css +52 -0
- data/example/noramark-reference-ja.nora +246 -0
- data/example/noramark-reference-ja_00001.xhtml +187 -0
- data/lib/nora_mark/html/{abstract_item_writer.rb → abstract_node_writer.rb} +3 -3
- data/lib/nora_mark/html/context.rb +3 -21
- data/lib/nora_mark/html/frontmatter_writer.rb +33 -0
- data/lib/nora_mark/html/generator.rb +122 -100
- data/lib/nora_mark/html/pages.rb +3 -9
- data/lib/nora_mark/html/paragraph_writer.rb +27 -23
- data/lib/nora_mark/html/tag_writer.rb +33 -34
- data/lib/nora_mark/html/writer_selector.rb +3 -3
- data/lib/nora_mark/node.rb +31 -0
- data/lib/nora_mark/parser.kpeg +133 -79
- data/lib/nora_mark/parser.kpeg.rb +1822 -1526
- data/lib/nora_mark/parser.rb +4 -23
- data/lib/nora_mark/version.rb +1 -1
- data/lib/nora_mark.rb +7 -2
- data/nora_mark.gemspec +1 -0
- data/spec/epub30-schemas/epub-nav-30.nvdl +16 -0
- data/spec/epub30-schemas/epub-nav-30.rnc +10 -0
- data/spec/epub30-schemas/epub-nav-30.sch +72 -0
- data/spec/epub30-schemas/epub-svg-30.nvdl +15 -0
- data/spec/epub30-schemas/epub-svg-30.rnc +15 -0
- data/spec/epub30-schemas/epub-svg-30.sch +10 -0
- data/spec/epub30-schemas/epub-xhtml-30.nvdl +15 -0
- data/spec/epub30-schemas/epub-xhtml-30.rnc +37 -0
- data/spec/epub30-schemas/epub-xhtml-30.sch +377 -0
- data/spec/epub30-schemas/epub30-catalog.xml +335 -0
- data/spec/epub30-schemas/media-overlay-30.nvdl +14 -0
- data/spec/epub30-schemas/media-overlay-30.rnc +46 -0
- data/spec/epub30-schemas/media-overlay-30.sch +9 -0
- data/spec/epub30-schemas/mod/datatypes.rnc +143 -0
- data/spec/epub30-schemas/mod/epub-mathml3-30.rnc +74 -0
- data/spec/epub30-schemas/mod/epub-prefix-attr.rnc +8 -0
- data/spec/epub30-schemas/mod/epub-ssml-attrs.rnc +11 -0
- data/spec/epub30-schemas/mod/epub-svg11-30.rnc +12 -0
- data/spec/epub30-schemas/mod/epub-svg11-re.sch +7 -0
- data/spec/epub30-schemas/mod/epub-switch.rnc +32 -0
- data/spec/epub30-schemas/mod/epub-trigger.rnc +17 -0
- data/spec/epub30-schemas/mod/epub-type-attr.rnc +7 -0
- data/spec/epub30-schemas/mod/epub-xhtml-mathml3-30.rnc +5 -0
- data/spec/epub30-schemas/mod/epub-xhtml-svg11-30.rnc +6 -0
- data/spec/epub30-schemas/mod/html5/LICENSE +23 -0
- data/spec/epub30-schemas/mod/html5/README +21 -0
- data/spec/epub30-schemas/mod/html5/html5-aria-30.rnc +105 -0
- data/spec/epub30-schemas/mod/html5/html5-attrib-30.rnc +44 -0
- data/spec/epub30-schemas/mod/html5/html5-document-30.rnc +44 -0
- data/spec/epub30-schemas/mod/html5/html5-edit-30.rnc +24 -0
- data/spec/epub30-schemas/mod/html5/html5-embed-30.rnc +155 -0
- data/spec/epub30-schemas/mod/html5/html5-forms-30.rnc +431 -0
- data/spec/epub30-schemas/mod/html5/html5-grouping-30.rnc +115 -0
- data/spec/epub30-schemas/mod/html5/html5-interactive-30.rnc +86 -0
- data/spec/epub30-schemas/mod/html5/html5-models-30.rnc +10 -0
- data/spec/epub30-schemas/mod/html5/html5-phrasing-30.rnc +134 -0
- data/spec/epub30-schemas/mod/html5/html5-script-30.rnc +164 -0
- data/spec/epub30-schemas/mod/html5/html5-sections-30.rnc +58 -0
- data/spec/epub30-schemas/mod/html5/html5-style-30.rnc +18 -0
- data/spec/epub30-schemas/mod/id-unique.sch +10 -0
- data/spec/epub30-schemas/mod/mathml/LICENSE +3 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-common.rnc +84 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-content.rnc +373 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-presentation.rnc +536 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-strict-content.rnc +60 -0
- data/spec/epub30-schemas/mod/security/LICENSE +4 -0
- data/spec/epub30-schemas/mod/security/Lenient-Encryption11-ghc.rnc +41 -0
- data/spec/epub30-schemas/mod/security/Lenient-Encryption11.rnc +39 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature-exclusiveC14N.rnc +25 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties-exclusiveC14N.rnc +32 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties.rnc +30 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature11.rnc +28 -0
- data/spec/epub30-schemas/mod/security/Strict-Encryption.rnc +27 -0
- data/spec/epub30-schemas/mod/security/Strict-Signature.rnc +22 -0
- data/spec/epub30-schemas/mod/security/exc-c14n.rnc +39 -0
- data/spec/epub30-schemas/mod/security/security_any.rnc +15 -0
- data/spec/epub30-schemas/mod/security/xenc-allowAnyForeign.rnc +25 -0
- data/spec/epub30-schemas/mod/security/xenc-schema-11.rnc +96 -0
- data/spec/epub30-schemas/mod/security/xenc-schema.rnc +145 -0
- data/spec/epub30-schemas/mod/security/xenc11-allowAnyForeign.rnc +19 -0
- data/spec/epub30-schemas/mod/security/xmldsig-allowAnyForeign.rnc +47 -0
- data/spec/epub30-schemas/mod/security/xmldsig-core-schema.rnc +276 -0
- data/spec/epub30-schemas/mod/security/xmldsig-filter2.rnc +16 -0
- data/spec/epub30-schemas/mod/security/xmldsig-properties-schema.rnc +34 -0
- data/spec/epub30-schemas/mod/security/xmldsig11-allowAnyForeign.rnc +18 -0
- data/spec/epub30-schemas/mod/security/xmldsig11-schema.rnc +133 -0
- data/spec/epub30-schemas/mod/security/xmlsec-ghc-allowAnyForeign.rnc +21 -0
- data/spec/epub30-schemas/mod/security/xmlsec-ghc-schema.rnc +42 -0
- data/spec/epub30-schemas/mod/svg11/LICENSE +1 -0
- data/spec/epub30-schemas/mod/svg11/README.txt +8 -0
- data/spec/epub30-schemas/mod/svg11/svg11-flat.rnc +3999 -0
- data/spec/epub30-schemas/ocf-container-30.rnc +16 -0
- data/spec/epub30-schemas/ocf-encryption-30.rnc +12 -0
- data/spec/epub30-schemas/ocf-signatures-30.rnc +8 -0
- data/spec/epub30-schemas/package-30.nvdl +14 -0
- data/spec/epub30-schemas/package-30.rnc +91 -0
- data/spec/epub30-schemas/package-30.sch +137 -0
- data/spec/jing-20091111/bin/jing.jar +0 -0
- data/spec/nora_mark_spec.rb +229 -68
- data/spec/spec_helper.rb +16 -0
- metadata +179 -6
- data/lib/nora_mark/html/header_writer.rb +0 -35
- data/spec/fixture/test_src_ja.nora +0 -50
data/spec/nora_mark_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe NoraMark do
|
|
8
8
|
describe 'convert' do
|
9
9
|
it 'should generate valid xhtml' do
|
10
10
|
text = 'some text'
|
11
|
-
noramark = NoraMark::Document.parse(text, :
|
11
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
12
12
|
xhtml = Nokogiri::XML::Document.parse(noramark.html[0])
|
13
13
|
expect(xhtml.root.name).to eq('html')
|
14
14
|
expect(xhtml.root.namespaces['xmlns']).to eq('http://www.w3.org/1999/xhtml')
|
@@ -19,7 +19,7 @@ describe NoraMark do
|
|
19
19
|
end
|
20
20
|
it 'should convert simple paragraph' do
|
21
21
|
text = "ここから、パラグラフがはじまります。\n「二行目です。」\n三行目です。\n\n\n ここから、次のパラグラフです。"
|
22
|
-
noramark = NoraMark::Document.parse(text, :
|
22
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
23
23
|
converted = noramark.html
|
24
24
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
25
25
|
expect(body.element_children.size).to eq 2
|
@@ -38,7 +38,27 @@ describe NoraMark do
|
|
38
38
|
end
|
39
39
|
it 'should convert simple paragraph in english mode' do
|
40
40
|
text = "paragraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
|
41
|
-
noramark = NoraMark::Document.parse(text, :
|
41
|
+
noramark = NoraMark::Document.parse(text, lang: 'en', title: 'the title')
|
42
|
+
converted = noramark.html
|
43
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
44
|
+
expect(body.element_children.size).to eq 2
|
45
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
46
|
+
['p',
|
47
|
+
'paragraph begins.', ['br', ''],
|
48
|
+
'2nd line.', ['br', ''],
|
49
|
+
'3rd line.'
|
50
|
+
]
|
51
|
+
)
|
52
|
+
|
53
|
+
expect(body.element_children[1].selector_and_children).to eq(
|
54
|
+
['p', 'next paragraph.']
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
it 'should convert simple paragraph in english mode specified in frontmatter' do
|
60
|
+
text = "---\nlang: en\ntitle: the title\n---\nparagraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
|
61
|
+
noramark = NoraMark::Document.parse(text)
|
42
62
|
converted = noramark.html
|
43
63
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
44
64
|
expect(body.element_children.size).to eq 2
|
@@ -57,7 +77,26 @@ describe NoraMark do
|
|
57
77
|
|
58
78
|
it 'should convert simple paragraph in japanese mode, but paragraph mode is default' do
|
59
79
|
text = "paragraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
|
60
|
-
noramark = NoraMark::Document.parse(text, :
|
80
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_style: :default)
|
81
|
+
converted = noramark.html
|
82
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
83
|
+
expect(body.element_children.size).to eq 2
|
84
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
85
|
+
['p',
|
86
|
+
'paragraph begins.', ['br', ''],
|
87
|
+
'2nd line.', ['br', ''],
|
88
|
+
'3rd line.'
|
89
|
+
]
|
90
|
+
)
|
91
|
+
|
92
|
+
expect(body.element_children[1].selector_and_children).to eq(
|
93
|
+
['p', 'next paragraph.']
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should convert simple paragraph in japanese mode, but paragraph mode is default (using frontmatter)' do
|
98
|
+
text = "---\nlang: ja\ntitle: the title\nparagraph_style: default\n---\nparagraph begins.\n2nd line.\n 3rd line.\n\n\n next paragraph."
|
99
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_styl: :default)
|
61
100
|
converted = noramark.html
|
62
101
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
63
102
|
expect(body.element_children.size).to eq 2
|
@@ -76,7 +115,7 @@ describe NoraMark do
|
|
76
115
|
|
77
116
|
it 'should convert paragraph with header' do
|
78
117
|
text = "h1: タイトルです。\r\nここから、パラグラフがはじまります。\n\nh2.column:ふたつめの見出しです。\n ここから、次のパラグラフです。\nh3.third.foo: クラスが複数ある見出しです"
|
79
|
-
noramark = NoraMark::Document.parse(text, :
|
118
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
80
119
|
converted = noramark.html
|
81
120
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
82
121
|
expect(body.element_children.size).to eq 5
|
@@ -97,7 +136,7 @@ describe NoraMark do
|
|
97
136
|
|
98
137
|
it 'should convert div and paragraph' do
|
99
138
|
text = "d {\n1st line. \n}"
|
100
|
-
noramark = NoraMark::Document.parse(text, :
|
139
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the document title')
|
101
140
|
converted = noramark.html
|
102
141
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
103
142
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -109,9 +148,10 @@ describe NoraMark do
|
|
109
148
|
)
|
110
149
|
end
|
111
150
|
|
151
|
+
|
112
152
|
it 'should convert div without pgroup' do
|
113
|
-
text = "d(wo-pgroup) {\n1st line. \n}"
|
114
|
-
noramark = NoraMark::Document.parse(text, :
|
153
|
+
text = "d('wo-pgroup') {\n1st line. \n}"
|
154
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
115
155
|
converted = noramark.html
|
116
156
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
117
157
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -123,7 +163,7 @@ describe NoraMark do
|
|
123
163
|
|
124
164
|
it 'should nest div without pgroup' do
|
125
165
|
text = "d(wo-pgroup) {\nd {\nnested.\n} \n}"
|
126
|
-
noramark = NoraMark::Document.parse(text, :
|
166
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
127
167
|
converted = noramark.html
|
128
168
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
129
169
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -137,7 +177,7 @@ describe NoraMark do
|
|
137
177
|
|
138
178
|
it 'should nest div without pgroup and with pgroup' do
|
139
179
|
text = "d(wo-pgroup) {\nd {\nnested.\n} \n}\nd {\nin pgroup\n}"
|
140
|
-
noramark = NoraMark::Document.parse(text, :
|
180
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
141
181
|
converted = noramark.html
|
142
182
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
143
183
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -157,7 +197,7 @@ describe NoraMark do
|
|
157
197
|
|
158
198
|
it 'should convert div with class' do
|
159
199
|
text = "d.preface-one {\n h1: title.\n}"
|
160
|
-
noramark = NoraMark::Document.parse(text, :
|
200
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
161
201
|
converted = noramark.html
|
162
202
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
163
203
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -169,7 +209,7 @@ describe NoraMark do
|
|
169
209
|
|
170
210
|
it 'should convert div with id and class' do
|
171
211
|
text = "d#thecontents.preface-one {\nh1: title.\n}"
|
172
|
-
noramark = NoraMark::Document.parse(text, :
|
212
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
173
213
|
converted = noramark.html
|
174
214
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
175
215
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -181,7 +221,7 @@ describe NoraMark do
|
|
181
221
|
|
182
222
|
it 'should convert nested div' do
|
183
223
|
text = "d.preface {\n outer div. \n d.nested {\n nested!\n}\nouter div again.\n}"
|
184
|
-
noramark = NoraMark::Document.parse(text, :
|
224
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
185
225
|
converted = noramark.html
|
186
226
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
187
227
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -203,7 +243,7 @@ describe NoraMark do
|
|
203
243
|
|
204
244
|
it 'should convert article' do
|
205
245
|
text = "art {\n in the article.\n}"
|
206
|
-
noramark = NoraMark::Document.parse(text, :
|
246
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
207
247
|
converted = noramark.html
|
208
248
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
209
249
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -217,7 +257,7 @@ describe NoraMark do
|
|
217
257
|
|
218
258
|
it 'should convert article with other notation' do
|
219
259
|
text = "arti {\n in the article.\n}"
|
220
|
-
noramark = NoraMark::Document.parse(text, :
|
260
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
221
261
|
converted = noramark.html
|
222
262
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
223
263
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -231,7 +271,7 @@ describe NoraMark do
|
|
231
271
|
|
232
272
|
it 'should convert article with yet anther notation' do
|
233
273
|
text = "article {\n in the article.\n}"
|
234
|
-
noramark = NoraMark::Document.parse(text, :
|
274
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
235
275
|
converted = noramark.html
|
236
276
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
237
277
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -245,7 +285,7 @@ describe NoraMark do
|
|
245
285
|
|
246
286
|
it 'should convert section ' do
|
247
287
|
text = "art {\nsec {\n section in the article. \n}\n}"
|
248
|
-
noramark = NoraMark::Document.parse(text, :
|
288
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
249
289
|
converted = noramark.html
|
250
290
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
251
291
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -261,7 +301,7 @@ describe NoraMark do
|
|
261
301
|
|
262
302
|
it 'should convert section with other notation' do
|
263
303
|
text = "art {\nsect {\n section in the article. \n}\n}"
|
264
|
-
noramark = NoraMark::Document.parse(text, :
|
304
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
265
305
|
converted = noramark.html
|
266
306
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
267
307
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -277,7 +317,7 @@ describe NoraMark do
|
|
277
317
|
|
278
318
|
it 'should convert section with yet other notation' do
|
279
319
|
text = "art {\nsection {\n section in the article. \n}\n}"
|
280
|
-
noramark = NoraMark::Document.parse(text, :
|
320
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
281
321
|
converted = noramark.html
|
282
322
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
283
323
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -291,11 +331,9 @@ describe NoraMark do
|
|
291
331
|
)
|
292
332
|
end
|
293
333
|
|
294
|
-
|
295
|
-
|
296
334
|
it 'should handle block image' do
|
297
|
-
text = "this is normal line.\nimage(./image1.jpg, alt text): caption text"
|
298
|
-
noramark = NoraMark::Document.parse(text, :
|
335
|
+
text = "this is normal line.\nimage(./image1.jpg, \"alt text\"): caption text"
|
336
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
299
337
|
converted = noramark.html
|
300
338
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
301
339
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -313,7 +351,7 @@ describe NoraMark do
|
|
313
351
|
|
314
352
|
it 'should handle block image with before caption' do
|
315
353
|
text = "this is normal line.\nimage(./image1.jpg, alt text, caption_before: true): caption text"
|
316
|
-
noramark = NoraMark::Document.parse(text, :
|
354
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
317
355
|
converted = noramark.html
|
318
356
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
319
357
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -331,7 +369,7 @@ describe NoraMark do
|
|
331
369
|
|
332
370
|
it 'should handle block image without caption' do
|
333
371
|
text = "this is normal line.\nimage(./image1.jpg, alt text):"
|
334
|
-
noramark = NoraMark::Document.parse(text, :
|
372
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
335
373
|
converted = noramark.html
|
336
374
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
337
375
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -345,10 +383,10 @@ describe NoraMark do
|
|
345
383
|
]
|
346
384
|
)
|
347
385
|
end
|
348
|
-
|
386
|
+
|
349
387
|
it 'should handle page change article' do
|
350
388
|
text = "this is start.\nnewpage(page changed):\nthis is second page.\nnewpage:\nand the third."
|
351
|
-
noramark = NoraMark::Document.parse(text, :
|
389
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
352
390
|
converted = noramark.html
|
353
391
|
expect(converted.size).to eq 3
|
354
392
|
body1 = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
@@ -379,7 +417,7 @@ describe NoraMark do
|
|
379
417
|
|
380
418
|
it 'should handle stylesheets' do
|
381
419
|
text = "d.styled {\n this is styled document.\n}"
|
382
|
-
noramark = NoraMark::Document.parse(text, :
|
420
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the document title', stylesheets: ['reset.css', 'mystyle.css'])
|
383
421
|
converted = noramark.html
|
384
422
|
head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
|
385
423
|
expect(head.element_children[0].a).to eq ['title', 'the document title']
|
@@ -389,7 +427,7 @@ describe NoraMark do
|
|
389
427
|
|
390
428
|
it 'should handle link' do
|
391
429
|
text = " link to [link(http://github.com/skoji/noramark){noramark repository}]. \ncan you see this?"
|
392
|
-
noramark = NoraMark::Document.parse(text, :
|
430
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
393
431
|
converted = noramark.html
|
394
432
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
395
433
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -406,7 +444,7 @@ describe NoraMark do
|
|
406
444
|
|
407
445
|
it 'should handle link with l' do
|
408
446
|
text = "link to [l(http://github.com/skoji/noramark){noramark repository}]. \ncan you see this?"
|
409
|
-
noramark = NoraMark::Document.parse(text, :
|
447
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
410
448
|
converted = noramark.html
|
411
449
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
412
450
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -423,7 +461,7 @@ describe NoraMark do
|
|
423
461
|
|
424
462
|
it 'should handle custom paragraph' do
|
425
463
|
text = "this is normal line.\np.custom: this text is in custom class."
|
426
|
-
noramark = NoraMark::Document.parse(text, :
|
464
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
427
465
|
converted = noramark.html
|
428
466
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
429
467
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -436,7 +474,7 @@ describe NoraMark do
|
|
436
474
|
|
437
475
|
it 'should handle span' do
|
438
476
|
text = "p.custom: this text is in [s.keyword{custom}] class."
|
439
|
-
noramark = NoraMark::Document.parse(text, :
|
477
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
440
478
|
converted = noramark.html
|
441
479
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
442
480
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -448,7 +486,7 @@ describe NoraMark do
|
|
448
486
|
|
449
487
|
it 'should handle any block' do
|
450
488
|
text = "this is normal line.\ncite {\n this block should be in cite. \n}"
|
451
|
-
noramark = NoraMark::Document.parse(text, :
|
489
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
452
490
|
converted = noramark.html
|
453
491
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
454
492
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -467,7 +505,7 @@ describe NoraMark do
|
|
467
505
|
|
468
506
|
it 'should handle inline image' do
|
469
507
|
text = "simple image [img(./image1.jpg, alt)]."
|
470
|
-
noramark = NoraMark::Document.parse(text, :
|
508
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
471
509
|
converted = noramark.html
|
472
510
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
473
511
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -479,7 +517,7 @@ describe NoraMark do
|
|
479
517
|
|
480
518
|
it 'should handle any inline' do
|
481
519
|
text = "should be [strong{marked as strong}]."
|
482
|
-
noramark = NoraMark::Document.parse(text, :
|
520
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
483
521
|
converted = noramark.html
|
484
522
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
485
523
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -490,7 +528,7 @@ describe NoraMark do
|
|
490
528
|
|
491
529
|
it 'should convert inline command within line block' do
|
492
530
|
text = "h1: [tcy{20}]縦中横タイトル"
|
493
|
-
noramark = NoraMark::Document.parse(text, :
|
531
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
494
532
|
converted = noramark.html
|
495
533
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
496
534
|
expect(body.element_children[0].selector_and_children).to eq ['h1', ['span.tcy', '20'], '縦中横タイトル']
|
@@ -498,7 +536,7 @@ describe NoraMark do
|
|
498
536
|
|
499
537
|
it 'should handle ruby' do
|
500
538
|
text = "[ruby(とんぼ){蜻蛉}]の[ruby(めがね){眼鏡}]はみずいろめがね"
|
501
|
-
noramark = NoraMark::Document.parse(text, :
|
539
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
502
540
|
converted = noramark.html
|
503
541
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
504
542
|
expect(body.element_children[0].selector_and_children).to eq ['div.pgroup', ['p',
|
@@ -510,7 +548,7 @@ describe NoraMark do
|
|
510
548
|
|
511
549
|
it 'should handle tatechuyoko' do
|
512
550
|
text = "[tcy{10}]年前のことだった"
|
513
|
-
noramark = NoraMark::Document.parse(text, :
|
551
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
514
552
|
converted = noramark.html
|
515
553
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
516
554
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -521,7 +559,7 @@ describe NoraMark do
|
|
521
559
|
|
522
560
|
it 'should handle ordered list ' do
|
523
561
|
text = "this is normal line.\n1: for the 1st.\n2: secondly, blah.\n3: and last...\nthe ordered list ends."
|
524
|
-
noramark = NoraMark::Document.parse(text, :
|
562
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
525
563
|
converted = noramark.html
|
526
564
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
527
565
|
expect(body.element_children.size).to eq 3
|
@@ -543,7 +581,7 @@ describe NoraMark do
|
|
543
581
|
|
544
582
|
it 'should handle unordered list ' do
|
545
583
|
text = "this is normal line.\n*: for the 1st.\n*: secondly, blah.\n*: and last...\nthe ordered list ends."
|
546
|
-
noramark = NoraMark::Document.parse(text, :
|
584
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
547
585
|
converted = noramark.html
|
548
586
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
549
587
|
expect(body.element_children.size).to eq 3
|
@@ -565,7 +603,7 @@ describe NoraMark do
|
|
565
603
|
|
566
604
|
it 'should handle definition list ' do
|
567
605
|
text = "this is normal line.\n;: 1st : this is the first definition\n;: 2nd : blah :blah.\n;: 3rd: this term is the last.\nthe list ends."
|
568
|
-
noramark = NoraMark::Document.parse(text, :
|
606
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
569
607
|
converted = noramark.html
|
570
608
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
571
609
|
expect(body.element_children.size).to eq 3
|
@@ -585,9 +623,31 @@ describe NoraMark do
|
|
585
623
|
])
|
586
624
|
end
|
587
625
|
|
626
|
+
it 'should handle long definition list ' do
|
627
|
+
text = "this is normal line.\n;: 1st {\n this is the first definition\n}\n;: 2nd { \nblah :blah.\n}\n;: 3rd{\n this term is the last.\n}\nthe list ends."
|
628
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
629
|
+
converted = noramark.html
|
630
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
631
|
+
expect(body.element_children.size).to eq 3
|
632
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
633
|
+
['div.pgroup',
|
634
|
+
['p', 'this is normal line.']
|
635
|
+
])
|
636
|
+
expect(body.element_children[1].selector_and_children).to eq(
|
637
|
+
['dl',
|
638
|
+
['dt', '1st'],['dd', ['div.pgroup', ['p', 'this is the first definition']]],
|
639
|
+
['dt', '2nd'],['dd', ['div.pgroup', ['p', 'blah :blah.']]],
|
640
|
+
['dt', '3rd'],['dd', ['div.pgroup', ['p', 'this term is the last.']]]
|
641
|
+
])
|
642
|
+
expect(body.element_children[2].selector_and_children).to eq(
|
643
|
+
['div.pgroup',
|
644
|
+
['p', 'the list ends.']
|
645
|
+
])
|
646
|
+
end
|
647
|
+
|
588
648
|
it 'should escape html' do
|
589
649
|
text = ";:definition<div>:</div>&"
|
590
|
-
noramark = NoraMark::Document.parse(text, :
|
650
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
591
651
|
converted = noramark.html
|
592
652
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
593
653
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -597,8 +657,14 @@ describe NoraMark do
|
|
597
657
|
end
|
598
658
|
|
599
659
|
it 'should specify stylesheets' do
|
600
|
-
text =
|
601
|
-
|
660
|
+
text = <<EOF
|
661
|
+
---
|
662
|
+
stylesheets: [ css/default.css, css/specific.css, [ css/iphone.css, 'only screen and (min-device-width : 320px) and (max-device-width : 480px)']]
|
663
|
+
---
|
664
|
+
text.
|
665
|
+
|
666
|
+
EOF
|
667
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the document title')
|
602
668
|
converted = noramark.html
|
603
669
|
head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
|
604
670
|
expect(head.element_children[0].a).to eq ['title', 'the document title']
|
@@ -614,8 +680,8 @@ describe NoraMark do
|
|
614
680
|
end
|
615
681
|
|
616
682
|
it 'should specify title' do
|
617
|
-
text = "
|
618
|
-
noramark = NoraMark::Document.parse(text, :
|
683
|
+
text = "---\ntitle: the title of the book in the text.\n---\n\ntext."
|
684
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
619
685
|
converted = noramark.html
|
620
686
|
head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
|
621
687
|
expect(head.element_children[0].a).to eq ['title', 'the title of the book in the text.']
|
@@ -628,8 +694,8 @@ describe NoraMark do
|
|
628
694
|
end
|
629
695
|
|
630
696
|
it 'should specify title on each page' do
|
631
|
-
text = "
|
632
|
-
noramark = NoraMark::Document.parse(text, :
|
697
|
+
text = "---\ntitle: page1\n---\n\n1st page.\nnewpage:\n---\ntitle: page2\n---\nh1:2nd page"
|
698
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title', paragraph_style: :use_paragraph_group)
|
633
699
|
converted = noramark.html
|
634
700
|
# 1st page
|
635
701
|
head = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:head')
|
@@ -649,8 +715,8 @@ describe NoraMark do
|
|
649
715
|
|
650
716
|
|
651
717
|
it 'should ignore comments' do
|
652
|
-
text = "# この行はコメントです\nここから、パラグラフがはじまります。\n # これもコメント\n「二行目です。」\n三行目です。\n\n# これもコメント\n\n
|
653
|
-
noramark = NoraMark::Document.parse(text, :
|
718
|
+
text = "# この行はコメントです\nここから、パラグラフがはじまります。\n # これもコメント\n「二行目です。」\n三行目です。\n\n# これもコメント\n\n ここから、次のパラグラフです。\n#最後のコメントです"
|
719
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
654
720
|
converted = noramark.html
|
655
721
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
656
722
|
expect(body.element_children.size).to eq 2
|
@@ -671,7 +737,7 @@ describe NoraMark do
|
|
671
737
|
|
672
738
|
it 'should handle preprocessor' do
|
673
739
|
text = "pre-preprocess text"
|
674
|
-
noramark = NoraMark::Document.parse(text, :
|
740
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title') do
|
675
741
|
|nora|
|
676
742
|
nora.preprocessor do
|
677
743
|
|text|
|
@@ -688,8 +754,8 @@ describe NoraMark do
|
|
688
754
|
end
|
689
755
|
|
690
756
|
it 'should convert h1 in article after title' do
|
691
|
-
text = "
|
692
|
-
noramark = NoraMark::Document.parse(text, :
|
757
|
+
text = "---\nstylesheets: css/default.css\ntitle: foo\n---\narticle.atogaki {\n\nh1: あとがき。\n\natogaki\n}"
|
758
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
693
759
|
converted = noramark.html
|
694
760
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
695
761
|
expect(body.element_children[0].selector_and_children).to eq(
|
@@ -703,31 +769,32 @@ describe NoraMark do
|
|
703
769
|
it 'should convert preformatted text' do
|
704
770
|
text = <<EOF
|
705
771
|
normal line.
|
706
|
-
pre
|
772
|
+
pre {//
|
707
773
|
d {
|
708
774
|
this will not converted to div or p or pgroup.
|
709
775
|
line_command: this will be not converted too.
|
710
776
|
}
|
711
|
-
|
777
|
+
//}
|
712
778
|
EOF
|
713
|
-
noramark = NoraMark::Document.parse(text, :
|
779
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
714
780
|
converted = noramark.html
|
715
781
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
716
782
|
expect(body.element_children[0].selector_and_children).to eq(["div.pgroup", ["p", "normal line."]])
|
717
783
|
expect(body.element_children[1].selector_and_children).to eq(["pre", "d {\n this will not converted to div or p or pgroup.\nline_command: this will be not converted too.\n}"])
|
718
784
|
end
|
785
|
+
|
719
786
|
it 'should convert preformatted code' do
|
720
787
|
text = <<EOF
|
721
788
|
normal line.
|
722
|
-
|
789
|
+
code {//
|
723
790
|
d {
|
724
791
|
this will not converted to div or p or pgroup.
|
725
792
|
line_command: this will be not converted too.
|
726
793
|
}
|
727
|
-
|
794
|
+
//}
|
728
795
|
normal line again.
|
729
796
|
EOF
|
730
|
-
noramark = NoraMark::Document.parse(text, :
|
797
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
731
798
|
converted = noramark.html
|
732
799
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
733
800
|
expect(body.element_children[0].selector_and_children).to eq(["div.pgroup", ["p", "normal line."]])
|
@@ -735,28 +802,89 @@ EOF
|
|
735
802
|
expect(body.element_children[2].selector_and_children).to eq(["div.pgroup", ["p", "normal line again."]])
|
736
803
|
end
|
737
804
|
|
805
|
+
it 'should convert preformatted code with language' do
|
806
|
+
text = <<EOF
|
807
|
+
normal line.
|
808
|
+
code {//ruby
|
809
|
+
# ruby code example.
|
810
|
+
"Hello, World".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]
|
811
|
+
//}
|
812
|
+
normal line again.
|
813
|
+
EOF
|
814
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
815
|
+
converted = noramark.html
|
816
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
817
|
+
expect(body.element_children[0].selector_and_children).to eq(["div.pgroup", ["p", "normal line."]])
|
818
|
+
expect(body.element_children[1].selector_and_children).to eq(["pre.code-ruby[data-code-language='ruby']", ["code", "# ruby code example.\n\"Hello, World\".split(',').map(&:strip).map(&:to_sym) # => [:Hello, :World]"]])
|
819
|
+
expect(body.element_children[2].selector_and_children).to eq(["div.pgroup", ["p", "normal line again."]])
|
820
|
+
end
|
821
|
+
|
822
|
+
it 'should convert preformatted text (simple notation)' do
|
823
|
+
text = <<EOF
|
824
|
+
normal line.
|
825
|
+
pre {
|
826
|
+
this [l(link){link}] will not be converted.
|
827
|
+
line_command: this will be not converted too.
|
828
|
+
}
|
829
|
+
normal line again.
|
830
|
+
EOF
|
831
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
832
|
+
converted = noramark.html
|
833
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
834
|
+
expect(body.element_children[0].selector_and_children).to eq(["div.pgroup", ["p", "normal line."]])
|
835
|
+
expect(body.element_children[1].selector_and_children).to eq(["pre", "this [l(link){link}] will not be converted.\nline_command: this will be not converted too."])
|
836
|
+
expect(body.element_children[2].selector_and_children).to eq(["div.pgroup", ["p", "normal line again."]])
|
837
|
+
end
|
838
|
+
it 'should convert preformatted code (simple notation)' do
|
839
|
+
text = <<EOF
|
840
|
+
normal line.
|
841
|
+
code {
|
842
|
+
line_command: this will be not converted too.
|
843
|
+
}
|
844
|
+
normal line again.
|
845
|
+
EOF
|
846
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
847
|
+
converted = noramark.html
|
848
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
849
|
+
expect(body.element_children[0].selector_and_children).to eq(["div.pgroup", ["p", "normal line."]])
|
850
|
+
expect(body.element_children[1].selector_and_children).to eq(["pre", ["code", "line_command: this will be not converted too."]])
|
851
|
+
expect(body.element_children[2].selector_and_children).to eq(["div.pgroup", ["p", "normal line again."]])
|
852
|
+
end
|
853
|
+
|
738
854
|
it 'should raise error' do
|
739
855
|
text = "d {\n block is\nd {\n nested but\nd {\n not terminated }"
|
740
|
-
expect { NoraMark::Document.parse(text, :
|
856
|
+
expect { NoraMark::Document.parse(text, lang: 'ja', title: 'foo') }.to raise_error KPeg::CompiledParser::ParseError
|
741
857
|
end
|
742
858
|
|
743
859
|
describe 'markdown style' do
|
744
860
|
it 'should convert markdown style heading' do
|
745
|
-
text = "=:
|
746
|
-
noramark = NoraMark::Document.parse(text, :
|
861
|
+
text = "=: タイトル です。\r\n\r\nこれは、セクションの中です。"
|
862
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
747
863
|
converted = noramark.html
|
748
864
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
749
865
|
expect(body.element_children.size).to eq 1
|
750
866
|
expect(body.element_children[0].selector_and_children).to eq(
|
751
867
|
['section',
|
752
|
-
['h1', '
|
868
|
+
['h1', 'タイトル です。'],
|
753
869
|
['div.pgroup',
|
754
870
|
['p', 'これは、セクションの中です。']]]
|
755
871
|
)
|
756
872
|
end
|
873
|
+
it 'should convert markdown style heading with empty body' do
|
874
|
+
text = "=: タイトルです。\n==: 次のタイトルです。これから書きます。"
|
875
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
876
|
+
converted = noramark.html
|
877
|
+
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
878
|
+
expect(body.element_children.size).to eq 1
|
879
|
+
expect(body.element_children[0].selector_and_children).to eq(
|
880
|
+
['section',
|
881
|
+
['h1', 'タイトルです。'],
|
882
|
+
['section',
|
883
|
+
['h2', '次のタイトルです。これから書きます。']]])
|
884
|
+
end
|
757
885
|
it 'should markdown style heading interrupted by other headed section' do
|
758
886
|
text = "=: タイトルです。\r\nこれは、セクションの中です。\n =: また次のセクションです。\n次のセクションの中です。"
|
759
|
-
noramark = NoraMark::Document.parse(text, :
|
887
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
760
888
|
converted = noramark.html
|
761
889
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
762
890
|
expect(body.element_children.size).to eq 2
|
@@ -774,7 +902,7 @@ EOF
|
|
774
902
|
end
|
775
903
|
it 'should markdown style heading not interrupted by other explicit section' do
|
776
904
|
text = "=: タイトルです。\r\nこれは、セクションの中です。\n section {\n h2: また次のセクションです。\n入れ子になります。\n}\nこのように。"
|
777
|
-
noramark = NoraMark::Document.parse(text, :
|
905
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
778
906
|
converted = noramark.html
|
779
907
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
780
908
|
expect(body.element_children.size).to eq 1
|
@@ -793,7 +921,7 @@ EOF
|
|
793
921
|
end
|
794
922
|
it 'should markdown style heading not interrupted by smaller section' do
|
795
923
|
text = "=: タイトルです。\r\nこれは、セクションの中です。\n ==: また次のセクションです。\n 入れ子になります。\n===: さらに中のセクション \nさらに入れ子になっているはず。\n=:ここで次のセクションです。\n脱出しているはずです。"
|
796
|
-
noramark = NoraMark::Document.parse(text, :
|
924
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
797
925
|
converted = noramark.html
|
798
926
|
body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
|
799
927
|
expect(body.element_children.size).to eq 2
|
@@ -818,23 +946,56 @@ EOF
|
|
818
946
|
|
819
947
|
end
|
820
948
|
end
|
949
|
+
|
821
950
|
describe 'create file' do
|
822
951
|
before { @basedir = File.join(File.dirname(__FILE__), 'created_files') }
|
823
952
|
after { Dir.glob(File.join(@basedir, '*.xhtml')) { |file| File.delete file } }
|
824
953
|
it 'should create default file' do
|
825
954
|
text = "some text"
|
826
|
-
noramark = NoraMark::Document.parse(text, :
|
955
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
|
827
956
|
noramark.html.write_as_files(directory: @basedir)
|
828
957
|
expect(File.basename(Dir.glob(File.join(@basedir, '*.xhtml'))[0])).to match /noramark_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}_00001.xhtml/
|
829
958
|
end
|
830
959
|
it 'should create named file' do
|
831
960
|
text = "some text\nnewpage:\nnext page"
|
832
|
-
noramark = NoraMark::Document.parse(text, :
|
961
|
+
noramark = NoraMark::Document.parse(text, lang: 'ja', title:'the document title', document_name: 'nora-test-file', sequence_format: '%03d' )
|
833
962
|
noramark.html.write_as_files(directory: @basedir)
|
834
963
|
files = Dir.glob(File.join(@basedir, '*.xhtml'))
|
835
964
|
expect(File.basename(files[0])).to eq 'nora-test-file_001.xhtml'
|
836
965
|
expect(File.basename(files[1])).to eq 'nora-test-file_002.xhtml'
|
837
966
|
end
|
838
967
|
end
|
968
|
+
describe 'parse and create manual' do
|
969
|
+
before {
|
970
|
+
@here = File.dirname(__FILE__)
|
971
|
+
@basedir = File.join(File.dirname(__FILE__), 'created_files')
|
972
|
+
@exampledir = File.join(@here, '..', 'example')
|
973
|
+
}
|
974
|
+
after { Dir.glob(File.join(@basedir, '*.xhtml')) { |file| File.delete file } }
|
975
|
+
it 'should create valid html5' do
|
976
|
+
noramark = NoraMark::Document.parse(File.open(File.join(@exampledir, 'noramark-reference-ja.nora')).read, document_name: 'noramark-reference-ja')
|
977
|
+
noramark.html.write_as_files(directory: @exampledir)
|
978
|
+
jar = File.join(@here, 'jing-20091111/bin/jing.jar')
|
979
|
+
schema = File.join(@here, 'epub30-schemas/epub-xhtml-30.rnc')
|
980
|
+
original_file = File.join(@exampledir, 'noramark-reference-ja_00001.xhtml')
|
981
|
+
file_to_validate = File.join(@basedir, 'noramark-reference-ja_00001.xhtml')
|
982
|
+
File.open(original_file) do
|
983
|
+
|original|
|
984
|
+
nokogiri_doc = Nokogiri::XML::Document.parse(original)
|
985
|
+
set = nokogiri_doc.xpath('//xmlns:pre[@data-code-language]')
|
986
|
+
set.remove_attr('data-code-language')
|
987
|
+
File.open(file_to_validate, 'w+') do
|
988
|
+
|to_validate|
|
989
|
+
to_validate << nokogiri_doc.to_s
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
993
|
+
@stdout = capture(:stdout) do
|
994
|
+
puts %x(java -jar #{jar} -c #{schema} #{file_to_validate})
|
995
|
+
end
|
996
|
+
expect(@stdout.strip).to eq ""
|
997
|
+
end
|
998
|
+
end
|
839
999
|
end
|
840
1000
|
end
|
1001
|
+
|