nora_mark 0.2beta7 → 0.2beta8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
+ require 'byebug'
5
+
4
6
  begin
5
7
  require 'rspec'
6
8
  rescue LoadError
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.dirname(__FILE__) + '/spec_helper.rb'
3
+ require File.dirname(__FILE__) + '/../lib/nora_mark'
4
+ require 'nokogiri'
5
+ require File.dirname(__FILE__) + '/nokogiri_test_helper.rb'
6
+
7
+ describe NoraMark::Transformer do
8
+ before do
9
+ @text = <<EOF
10
+ ---
11
+ title: the title
12
+ lang: ja
13
+ custom_data: [custom1, custom2]
14
+ ---
15
+ # section 1
16
+
17
+ d.class-1 {
18
+ text is here
19
+ }
20
+
21
+ EOF
22
+ @parsed = NoraMark::Document.parse(@text)
23
+ end
24
+ it 'can access frontmatter' do
25
+ @parsed.add_transformer(generator: :html) do
26
+ modify 'd' do
27
+ @node.classes = [@frontmatter['custom_data'][0]]
28
+ end
29
+ end
30
+ body = Nokogiri::XML::Document.parse(@parsed.html[0]).root.at_xpath('xmlns:body')
31
+ expect(body.element_children[0].selector_and_children())
32
+ .to eq(
33
+ ['section', ['h1', 'section 1'],
34
+ ['div.custom1', ['div.pgroup', ['p', 'text is here']]]]
35
+ )
36
+ end
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nora_mark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2beta7
4
+ version: 0.2beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOJIMA Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kpeg
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: nokogiri
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +80,7 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: 1.6.0
69
- description: simple and customizable text markup language for EPUB
83
+ description: Simple and customizable text markup language for EPUB/XHTML
70
84
  email:
71
85
  - skoji@mac.com
72
86
  executables:
@@ -82,22 +96,25 @@ files:
82
96
  - README.md
83
97
  - Rakefile
84
98
  - bin/nora2html
99
+ - emacs-mode/noramark-mode.el
100
+ - example/koujin.nora
85
101
  - example/nora-simple-ja.css
86
102
  - example/nora-simple.css
87
103
  - example/noramark-reference-ja.nora
88
104
  - example/noramark-reference-ja_00001.xhtml
89
105
  - lib/nora_mark.rb
106
+ - lib/nora_mark/document.rb
107
+ - lib/nora_mark/extensions.rb
90
108
  - lib/nora_mark/html/abstract_node_writer.rb
91
109
  - lib/nora_mark/html/context.rb
110
+ - lib/nora_mark/html/default_transformer.rb
92
111
  - lib/nora_mark/html/frontmatter_writer.rb
93
112
  - lib/nora_mark/html/generator.rb
94
113
  - lib/nora_mark/html/pages.rb
95
114
  - lib/nora_mark/html/paragraph_writer.rb
96
115
  - lib/nora_mark/html/tag_writer.rb
97
116
  - lib/nora_mark/html/util.rb
98
- - lib/nora_mark/html/writer_selector.rb
99
117
  - lib/nora_mark/node.rb
100
- - lib/nora_mark/node_builder.rb
101
118
  - lib/nora_mark/node_set.rb
102
119
  - lib/nora_mark/node_util.rb
103
120
  - lib/nora_mark/parser.kpeg
@@ -185,9 +202,11 @@ files:
185
202
  - spec/epub30-schemas/package-30.rnc
186
203
  - spec/epub30-schemas/package-30.sch
187
204
  - spec/jing-20091111/bin/jing.jar
205
+ - spec/node_spec.rb
188
206
  - spec/nokogiri_test_helper.rb
189
207
  - spec/nora_mark_spec.rb
190
208
  - spec/spec_helper.rb
209
+ - spec/transformer_spec.rb
191
210
  homepage: ''
192
211
  licenses: []
193
212
  metadata: {}
@@ -210,7 +229,7 @@ rubyforge_project:
210
229
  rubygems_version: 2.2.0
211
230
  signing_key:
212
231
  specification_version: 4
213
- summary: simple and customizable text markup language for EPUB
232
+ summary: Simple and customizable text markup language for EPUB/XHTML
214
233
  test_files:
215
234
  - spec/created_files/.gitignore
216
235
  - spec/epub30-schemas/epub-nav-30.nvdl
@@ -291,6 +310,8 @@ test_files:
291
310
  - spec/epub30-schemas/package-30.rnc
292
311
  - spec/epub30-schemas/package-30.sch
293
312
  - spec/jing-20091111/bin/jing.jar
313
+ - spec/node_spec.rb
294
314
  - spec/nokogiri_test_helper.rb
295
315
  - spec/nora_mark_spec.rb
296
316
  - spec/spec_helper.rb
317
+ - spec/transformer_spec.rb
@@ -1,24 +0,0 @@
1
- module NoraMark
2
- module Html
3
- class WriterSelector
4
- def initialize(generator, tag_writers = {}, trailer_default: "\n" )
5
- @generator = generator
6
- @common_tag_writer = TagWriter.create(nil, @generator, trailer: trailer_default)
7
- @tag_writers = tag_writers
8
- if !trailer_default.nil?
9
- @tag_writers.each { |k, t|
10
- if t.is_a? TagWriter
11
- t.trailer = trailer_default
12
- end
13
- }
14
- end
15
-
16
- end
17
-
18
- def write(node)
19
- writer = @tag_writers[node.name] || @common_tag_writer
20
- writer.write(node)
21
- end
22
- end
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- module NoraMark
2
- class NodeBuilder
3
- include NodeUtil
4
- def initialize(original_node, options)
5
- @node = original_node
6
- @options = options
7
- end
8
-
9
- def modify(&block)
10
- instance_eval &block
11
- end
12
-
13
- def replace(&block)
14
- new_node = instance_eval &block
15
- @node.replace new_node
16
- end
17
- end
18
- end