nora_mark 0.2beta11 → 0.2beta12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bff53f9401fc6525a0bdd225bb589f4a23190307
4
- data.tar.gz: 4c13e03922f95694c20a95f50c5f16df14254f5a
3
+ metadata.gz: 878b5a25f32b34e6c9ba1cf27418f876e6ee3bed
4
+ data.tar.gz: d0079061039cf71ee91f554cafefd8613cb06895
5
5
  SHA512:
6
- metadata.gz: 196f90eafc13171a5fcd7c59c126ffc5e5ef83f0329d7d6630aa25afdf6c1800e9045b6cc20c93a4d7db23ec3b0ea347526c1d7dc165ab9b48683d793cc7e658
7
- data.tar.gz: 2cbf86b01d093cb5a3745495a84fb76e1e17ffa3e473a0e7f71db274499984c0e333b0adbbf240d6248fc10f58f52aa5f7085ef031834dce538d5d42e3065532
6
+ metadata.gz: 9b85d6e2c5ac7d9f05fba7548976874a63176573fd3fb3245934cde97b627a948e1dff94717622625c1d3aa3b136506d0511181bcac47d5673314e274963c064
7
+ data.tar.gz: 42cc2bc8cbc5181f365e759c6c61e883b513ae8d8e148d10ed7e53abb6ee5553004889c90e866b2c675fbd434e0fb2e70393aea094fb92de384fc92ab27a1614
@@ -1,3 +1,11 @@
1
+ # version 0.2beta8 to 0.2beta12
2
+
3
+ * Plugin API for generator
4
+ * Support video and audio tag
5
+ * Support nested unordered list
6
+ * Support GFM style inline code block
7
+ * Tilt Adapter (@KitaitiMakoto)
8
+
1
9
  # version 0.2beta7 (NoraMark beta)
2
10
 
3
11
  * new table of contents feature. assign table of contents heading to every heading element (h1-h2 and Markdown style header)
data/LICENSE CHANGED
@@ -1,22 +1,29 @@
1
- Copyright (c) 2012 KOJIMA Satoshi
1
+ # LICENSE:
2
2
 
3
- MIT License
3
+ (The New BSD License)
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Copyright (c) 2012-2014, KOJIMA Satoshi
6
+ All rights reserved.
12
7
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are met:
15
10
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ * Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+ * Neither the name of the <organization> nor the
17
+ names of its contributors may be used to endorse or promote products
18
+ derived from this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
24
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -335,10 +335,12 @@ Result.
335
335
  </body>
336
336
  </html>
337
337
  ```
338
- ### HTML generator default transformer
338
+ ### Transformer examples
339
339
 
340
340
  [HTML generator default transformer](https://github.com/skoji/noramark/blob/master/lib/nora_mark/html/default_transformer.rb) is a good example of transformer.
341
341
 
342
+ HTMLBook also implements its own [transformer](https://github.com/skoji/nora_mark_htmlbook/blob/master/lib/nora_mark_htmlbook/transformer.rb).
343
+
342
344
  ## noramark-mode.el
343
345
 
344
346
  Experimental implementation of noramark major mode is available here. It provides font-lock for NoraMark syntax and supports outline-minor-mode for the present.
@@ -1,7 +1,7 @@
1
1
  module NoraMark
2
2
  module Html
3
3
  class Context
4
- attr_accessor :title, :head_inserters, :lang, :stylesheets, :enable_pgroup, :render_parameter
4
+ attr_accessor :title, :head_inserters, :lang, :stylesheets, :enable_pgroup, :render_parameter, :namespaces, :metas
5
5
  def initialize(param = {})
6
6
  @head_inserters = []
7
7
  @lang = param[:lang] || 'en'
@@ -10,11 +10,12 @@ module NoraMark
10
10
  @enable_pgroup = param[:enable_pgroup] || true
11
11
  self.paragraph_style= param[:paragraph_style]
12
12
  @pages = Pages.new(param[:sequence_format])
13
- @block_delimiter_stack = []
13
+ @namespaces = {}
14
+ @metas = []
14
15
  @render_parameter = {}
15
16
  head_inserter do
16
17
  ret = ""
17
- @stylesheets.each { |s|
18
+ @stylesheets.each do |s|
18
19
  if s.is_a? String
19
20
  ret << "<link rel=\"stylesheet\" type=\"text/css\" href=\"#{s}\" />\n"
20
21
  elsif s.is_a? Array
@@ -22,7 +23,12 @@ module NoraMark
22
23
  else
23
24
  raise "Can't use #{s} as a stylesheet"
24
25
  end
25
- }
26
+ end
27
+ ret << @metas.map do |meta|
28
+ "<meta " + meta.map do |k,v|
29
+ "#{k}=\"#{v}\""
30
+ end.join(" ") + " />"
31
+ end.join("\n")
26
32
  ret
27
33
  end
28
34
  end
@@ -60,7 +66,11 @@ module NoraMark
60
66
  end_html
61
67
  end
62
68
  page = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
63
- page << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"#{@lang}\" xml:lang=\"#{@lang}\">\n"
69
+ page << "<html xmlns=\"http://www.w3.org/1999/xhtml\""
70
+ page << @namespaces.map do |k,v|
71
+ "xmlns:#{k}=\"#{v}\""
72
+ end.join(' ')
73
+ page << " lang=\"#{@lang}\" xml:lang=\"#{@lang}\">\n"
64
74
  page << "<head>\n"
65
75
  page << "<title>#{@title}</title>\n"
66
76
  @head_inserters.each {
@@ -18,6 +18,12 @@ module NoraMark
18
18
  end,
19
19
  paragraph_style: proc do |value|
20
20
  @context.paragraph_style = value.strip.to_sym
21
+ end,
22
+ namespace: proc do |value|
23
+ @context.namespaces.merge! value
24
+ end,
25
+ meta: proc do |value|
26
+ @context.metas << value
21
27
  end
22
28
  }
23
29
  end
@@ -1,3 +1,3 @@
1
1
  module NoraMark
2
- VERSION = "0.2beta11"
2
+ VERSION = "0.2beta12"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'tilt'
2
+ require 'nora_mark'
3
+
4
+ module Tilt
5
+ class NoraMarkTemplate < Template
6
+ protected
7
+
8
+ def prepare
9
+ @document = NoraMark::Document.parse(data).render_parameter(nonpaged: true)
10
+ end
11
+
12
+ def evaluate(scope, locals, &block)
13
+ @html ||= @document.html[0]
14
+ end
15
+ end
16
+
17
+ register NoraMarkTemplate, 'nora'
18
+ end
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.required_ruby_version = '>= 2.0.0'
19
19
  gem.add_dependency "kpeg"
20
+ gem.add_development_dependency "tilt", ">= 2.0"
20
21
  gem.add_development_dependency "rspec", "~> 2.14"
21
22
  gem.add_development_dependency "rake"
22
23
  gem.add_development_dependency "byebug"
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
3
+ <head>
4
+ <title>test title</title>
5
+ <link rel="stylesheet" type="text/css" href="css/normalize.css" />
6
+ <link rel="stylesheet" type="text/css" href="css/main.css" />
7
+ </head>
8
+ <body><article><h1 id='heading_index_1'>header 1</h1>
9
+ <div class='pgroup'><p>article comes here.</p>
10
+ <p>linebreak will produce paragraph.</p>
11
+ </div>
12
+ <div class='pgroup'><p>blank line will procude div.pgroup.</p>
13
+ </div>
14
+ <div class='column'><div class='pgroup'><p>This block will produce div.column.</p>
15
+ <p>Inline commands like <a href='http://github.com/skoji/nora_mark/'>this</a> and <span class='strong'>this</span> is available.</p>
16
+ </div>
17
+ </div>
18
+ </article>
19
+ </body>
20
+ </html>
@@ -0,0 +1,18 @@
1
+ ---
2
+ lang: ja
3
+ title: test title
4
+ stylesheets: [css/normalize.css, css/main.css]
5
+ ---
6
+
7
+ art {
8
+ h1: header 1
9
+ article comes here.
10
+ linebreak will produce paragraph.
11
+
12
+ blank line will procude div.pgroup.
13
+
14
+ d.column {
15
+ This block will produce div.column.
16
+ Inline commands like [link(http://github.com/skoji/nora_mark/){this}] and [sp.strong{this}] is available.
17
+ }
18
+ }
@@ -1436,5 +1436,34 @@ EOF
1436
1436
  )
1437
1437
  end
1438
1438
  end
1439
+ describe 'Frontmatter MetaData' do
1440
+ it 'handle namespace' do
1441
+ text = <<EOF
1442
+ ---
1443
+ namespace: { epub: "http://www.idpf.org/2007/ops" }
1444
+ ---
1445
+ text
1446
+ EOF
1447
+ converted = NoraMark::Document.parse(text)
1448
+ xhtml = Nokogiri::XML::Document.parse(converted.html[0])
1449
+ expect(xhtml.root.namespaces['xmlns:epub'])
1450
+ .to eq 'http://www.idpf.org/2007/ops'
1451
+ end
1452
+
1453
+ it 'handle meta tag' do
1454
+ text = <<EOF
1455
+ ---
1456
+ meta: { name: mymeta, content: mycontent }
1457
+ namespace: { epub: "http://www.idpf.org/2007/ops" }
1458
+ ---
1459
+ text
1460
+ EOF
1461
+ converted = NoraMark::Document.parse(text)
1462
+ xhtml = Nokogiri::XML::Document.parse(converted.html[0])
1463
+ expect(xhtml.root.at_xpath('xmlns:head/xmlns:body')).to be_nil
1464
+ expect(xhtml.root.at_xpath('xmlns:head/xmlns:meta').selector_and_children)
1465
+ .to eq ["meta[name='mymeta'][content='mycontent']"]
1466
+ end
1467
+ end
1439
1468
  end
1440
1469
 
@@ -0,0 +1,16 @@
1
+ require_relative 'spec_helper'
2
+ require 'pathname'
3
+ require 'tilt/nora_mark'
4
+
5
+ describe Tilt::NoraMarkTemplate do
6
+ let(:fixtures_dir) { Pathname.new(__dir__) + 'fixtures/tilt' }
7
+ subject { Tilt.new(fixtures_dir + 'nora/sample.nora') }
8
+
9
+ it "should be registered for '.nora' files" do
10
+ expect(subject).to be_an_instance_of(Tilt::NoraMarkTemplate)
11
+ end
12
+
13
+ it "should convert '.nora' files to HTML" do
14
+ expect(subject.render).to eq (fixtures_dir + 'html/sample.html').read
15
+ end
16
+ 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.2beta11
4
+ version: 0.2beta12
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-05-08 00:00:00.000000000 Z
11
+ date: 2014-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kpeg
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tilt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +137,7 @@ files:
123
137
  - lib/nora_mark/parser.rb
124
138
  - lib/nora_mark/transformer.rb
125
139
  - lib/nora_mark/version.rb
140
+ - lib/tilt/nora_mark.rb
126
141
  - nora_mark.gemspec
127
142
  - spec/created_files/.gitignore
128
143
  - spec/epub30-schemas/epub-nav-30.nvdl
@@ -204,11 +219,14 @@ files:
204
219
  - spec/epub30-schemas/package-30.sch
205
220
  - spec/extensions_spec.rb
206
221
  - spec/fixtures/test-plugins/nora_mark_tester.rb
222
+ - spec/fixtures/tilt/html/sample.html
223
+ - spec/fixtures/tilt/nora/sample.nora
207
224
  - spec/jing-20091111/bin/jing.jar
208
225
  - spec/node_spec.rb
209
226
  - spec/nokogiri_test_helper.rb
210
227
  - spec/nora_mark_spec.rb
211
228
  - spec/spec_helper.rb
229
+ - spec/tilt_spec.rb
212
230
  - spec/transformer_spec.rb
213
231
  homepage: ''
214
232
  licenses: []
@@ -314,9 +332,12 @@ test_files:
314
332
  - spec/epub30-schemas/package-30.sch
315
333
  - spec/extensions_spec.rb
316
334
  - spec/fixtures/test-plugins/nora_mark_tester.rb
335
+ - spec/fixtures/tilt/html/sample.html
336
+ - spec/fixtures/tilt/nora/sample.nora
317
337
  - spec/jing-20091111/bin/jing.jar
318
338
  - spec/node_spec.rb
319
339
  - spec/nokogiri_test_helper.rb
320
340
  - spec/nora_mark_spec.rb
321
341
  - spec/spec_helper.rb
342
+ - spec/tilt_spec.rb
322
343
  - spec/transformer_spec.rb