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 +4 -4
- data/.gitignore +1 -0
- data/lib/nora_mark/html/context.rb +2 -2
- data/lib/nora_mark/html/default_transformer.rb +6 -1
- data/lib/nora_mark/html/generator.rb +3 -0
- data/lib/nora_mark/html/raw_text_block_writer.rb +12 -0
- data/lib/nora_mark/node.rb +1 -1
- data/lib/nora_mark/rake_task.rb +9 -5
- data/lib/nora_mark/version.rb +1 -1
- data/spec/nora_mark_spec.rb +38 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bab7f5959bf222485ec011a400b45a59ecf32b9
|
4
|
+
data.tar.gz: 82db31a87f16a58e7ec20cbad96a2af68debc16a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d38219f488f9317ee28bdf8379f0c2e58581888491ab4d442d306d73ef94b785ade9a3a8ad890790d4c47d849ae05eed3c83a33ff47ce2156edc411fe6a4535
|
7
|
+
data.tar.gz: d4bffde774cb6a1c4369306428a0465954fe5216680d0b4bc6558647a9de6fdd95f359b7248d22e06c64c1c4cac82baf8bf5b94a7b9bed4ef8ce095468d504eb
|
data/.gitignore
CHANGED
@@ -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[:
|
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[:
|
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
|
-
|
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: ''),
|
data/lib/nora_mark/node.rb
CHANGED
data/lib/nora_mark/rake_task.rb
CHANGED
@@ -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|
|
data/lib/nora_mark/version.rb
CHANGED
data/spec/nora_mark_spec.rb
CHANGED
@@ -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.
|
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-
|
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
|