nora_mark 0.2beta16 → 0.2beta18

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: d90789f0a20df993346e159dd0b37cdd1f664f9c
4
- data.tar.gz: 4c373042623881fcc820041c5454219d12c2f2ca
3
+ metadata.gz: 1bab7f5959bf222485ec011a400b45a59ecf32b9
4
+ data.tar.gz: 82db31a87f16a58e7ec20cbad96a2af68debc16a
5
5
  SHA512:
6
- metadata.gz: eb21f8791bccb24784e2761a4aa3bbe92c77723f83643acf5a60a33e84db5715b99b824b0b77e331c91d83600286d7b87198fff6fce101ca1fbe34d01367e0e5
7
- data.tar.gz: 8797e08d2c24486f596028f6b65f036c4097f5126ae058b29feae8dc7a859c4267a250ebeab02b6dc86f4930256f41363e620b1d600a02a94cdbb894533e3068
6
+ metadata.gz: 3d38219f488f9317ee28bdf8379f0c2e58581888491ab4d442d306d73ef94b785ade9a3a8ad890790d4c47d849ae05eed3c83a33ff47ce2156edc411fe6a4535
7
+ data.tar.gz: d4bffde774cb6a1c4369306428a0465954fe5216680d0b4bc6558647a9de6fdd95f359b7248d22e06c64c1c4cac82baf8bf5b94a7b9bed4ef8ce095468d504eb
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ spec/reports
17
17
  test/tmp
18
18
  test/version_tmp
19
19
  tmp
20
+ o
@@ -94,7 +94,7 @@ module NoraMark
94
94
 
95
95
  # save metadata written with Frontmatter Writer
96
96
  def save_default_metas
97
- @default_param[:styleheets] ||= @stylesheets if !@stylesheets.nil? && @stylesheets.size > 0
97
+ @default_param[:stylesheets] ||= @stylesheets if !@stylesheets.nil? && @stylesheets.size > 0
98
98
  @default_param[:title] ||= @title
99
99
  @default_param[:lang] ||= @lang
100
100
  @default_param[:paragraph_style] ||= @paragraph_style
@@ -103,7 +103,7 @@ module NoraMark
103
103
  end
104
104
 
105
105
  def restore_metas
106
- @stylesheets = @default_param[:styleheets] || @stylesheets
106
+ @stylesheets = @default_param[:stylesheets] || @stylesheets
107
107
  @title = @default_param[:title] || @title
108
108
  @lang = @default_param[:lang] || @lang
109
109
  @paragraph_style = @default_param[:paragraph_style] || @paragraph_style
@@ -108,7 +108,12 @@ module NoraMark
108
108
  end
109
109
 
110
110
  replace({type: :HeadedSection}) do
111
- block('section', [ block("h#{@node.level}", @node.heading, ids: @node.n[:heading_id], n: {chop_last_space: true}) ] + @node.children, template: @node)
111
+ if @node.named_params[:without_header]
112
+ content = @node.children
113
+ else
114
+ content = [ block("h#{@node.level}", @node.heading, ids: @node.n[:heading_id], n: {chop_last_space: true}) ] + @node.children
115
+ end
116
+ block('section', content, template: @node)
112
117
  end
113
118
 
114
119
  replace ({type: :CodeInline}) do
@@ -6,6 +6,7 @@ require 'nora_mark/html/tag_writer'
6
6
  require 'nora_mark/html/frontmatter_writer'
7
7
  require 'nora_mark/html/paragraph_writer'
8
8
  require 'nora_mark/html/abstract_node_writer'
9
+ require 'nora_mark/html/raw_text_block_writer'
9
10
  require 'nora_mark/html/default_transformer'
10
11
 
11
12
  module NoraMark
@@ -22,6 +23,7 @@ module NoraMark
22
23
  frontmatter_writer = FrontmatterWriter.new self
23
24
  paragraph_writer = ParagraphWriter.new self
24
25
  abstract_node_writer = AbstractNodeWriter.new self
26
+ raw_writer = RawTextBlockWriter.new self
25
27
  page_writer = TagWriter.create('body', self,
26
28
  node_preprocessor: proc do |node|
27
29
  @context.end_html
@@ -35,6 +37,7 @@ module NoraMark
35
37
  end);
36
38
 
37
39
  @writers = {
40
+ Text => raw_writer,
38
41
  Paragraph => paragraph_writer,
39
42
  ParagraphGroup => paragraph_writer,
40
43
  Inline =>TagWriter.create(nil, self, trailer: ''),
@@ -0,0 +1,12 @@
1
+ module NoraMark
2
+ module Html
3
+ class RawTextBlockWriter
4
+ def initialize(generator)
5
+ @generator = generator
6
+ end
7
+ def write(node)
8
+ @generator.to_html node.text
9
+ end
10
+ end
11
+ end
12
+ end
@@ -172,7 +172,7 @@ module NoraMark
172
172
  node.unlink
173
173
  node
174
174
  end
175
- parent.children_replaced
175
+ parent.children_replaced if parent
176
176
  r
177
177
  end
178
178
 
@@ -3,7 +3,7 @@ require 'rake/tasklib'
3
3
 
4
4
  module NoraMark
5
5
  class RakeTask < ::Rake::TaskLib
6
- attr_accessor :lang, :page_number_digits, :write_toc_file
6
+ attr_accessor :lang, :page_number_digits, :title, :stylesheets, :write_toc_file
7
7
  def initialize(lang: 'en')
8
8
  @preprocessors = []
9
9
  @transformers = []
@@ -40,12 +40,16 @@ module NoraMark
40
40
  dir = File.dirname File.expand_path(t.source)
41
41
  basename = File.basename(t.source, '.txt')
42
42
  transformer_name = File.join dir, basename + '-transform.rb'
43
+ parameters = {
44
+ :lang => @lang.to_s,
45
+ :sequence_format => "%0#{page_number_digits}d",
46
+ :document_name=>t.name.sub(/_[0-9]{#{page_number_digits}}\.xhtml/, '')
47
+ }
48
+ parameters[:stylesheets] = @stylesheets unless @stylesheets.nil?
49
+ parameters[:title] = @title unless @title.nil?
43
50
  @nora =
44
51
  NoraMark::Document.parse(
45
- File.open(t.source),
46
- :lang => @lang.to_s,
47
- :sequence_format => "%0#{page_number_digits}d",
48
- :document_name=>t.name.sub(/_[0-9]{#{page_number_digits}}\.xhtml/, '')) do
52
+ File.open(t.source), parameters) do
49
53
  |doc|
50
54
  @preprocessors.each do
51
55
  |prepro|
@@ -1,3 +1,3 @@
1
1
  module NoraMark
2
- VERSION = "0.2beta16"
2
+ VERSION = "0.2beta18"
3
3
  end
@@ -1203,7 +1203,29 @@ EOF
1203
1203
  expect(body.element_children[2].selector_and_children)
1204
1204
  .to eq(["div.pgroup", ["p", "normal line again."]])
1205
1205
  end
1206
-
1206
+ it 'convert noescape block' do
1207
+ text = <<EOF
1208
+ normal line.
1209
+ noescape {
1210
+ <table>
1211
+ <tr><td>you can write anything here.</td></tr>
1212
+ </table>
1213
+ }
1214
+ normal line again.
1215
+ EOF
1216
+ noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
1217
+ converted = noramark.html
1218
+ body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
1219
+ expect(body.element_children[0].selector_and_children)
1220
+ .to eq(["div.pgroup", ["p", "normal line."]])
1221
+ expect(body.element_children[1].selector_and_children)
1222
+ .to eq(
1223
+ ["table",
1224
+ ["tr",
1225
+ ["td", 'you can write anything here.']]])
1226
+ expect(body.element_children[2].selector_and_children)
1227
+ .to eq(["div.pgroup", ["p", "normal line again."]])
1228
+ end
1207
1229
  end
1208
1230
 
1209
1231
  describe 'markdown style' do
@@ -1221,6 +1243,21 @@ EOF
1221
1243
  ['p', 'これは、セクションの中です。']]]
1222
1244
  )
1223
1245
  end
1246
+
1247
+ it 'should convert markdown style heading : without header' do
1248
+ text = "#[without_header: true]: タイトル です。\r\n\r\nこれは、セクションの中です。"
1249
+ noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
1250
+ converted = noramark.html
1251
+ body = Nokogiri::XML::Document.parse(converted[0]).root.at_xpath('xmlns:body')
1252
+ expect(body.element_children.size).to eq 1
1253
+ expect(body.element_children[0].selector_and_children)
1254
+ .to eq(
1255
+ ['section',
1256
+ ['div.pgroup',
1257
+ ['p', 'これは、セクションの中です。']]]
1258
+ )
1259
+ end
1260
+
1224
1261
  it 'should convert markdown style heading with empty body' do
1225
1262
  text = "# タイトルです。\n* 中身です。\n\n## 次のタイトルです。これから書きます。\n\n## ここもこれから。"
1226
1263
  noramark = NoraMark::Document.parse(text, lang: 'ja', title: 'the title')
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.2beta16
4
+ version: 0.2beta18
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOJIMA Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kpeg
@@ -126,6 +126,7 @@ files:
126
126
  - lib/nora_mark/html/generator.rb
127
127
  - lib/nora_mark/html/pages.rb
128
128
  - lib/nora_mark/html/paragraph_writer.rb
129
+ - lib/nora_mark/html/raw_text_block_writer.rb
129
130
  - lib/nora_mark/html/tag_writer.rb
130
131
  - lib/nora_mark/html/util.rb
131
132
  - lib/nora_mark/node.rb