arti_mark 0.0.1.beta0 → 0.0.1.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/arti_mark/context.rb +2 -1
- data/lib/arti_mark/result.rb +25 -0
- data/lib/arti_mark/version.rb +1 -1
- data/lib/arti_mark.rb +1 -0
- metadata +3 -4
- data/lib/arti_mark/result_holder.rb +0 -74
- data/memo.txt +0 -22
data/lib/arti_mark/context.rb
CHANGED
@@ -9,7 +9,7 @@ module ArtiMark
|
|
9
9
|
@stylesheets = param[:stylesheets] || []
|
10
10
|
@stylesheets_alt = param[:stylesheets_alt] || []
|
11
11
|
@enable_pgroup = param[:enable_pgroup] || true
|
12
|
-
@pages =
|
12
|
+
@pages = Result.new
|
13
13
|
head_inserter do
|
14
14
|
ret = ""
|
15
15
|
@stylesheets.each { |s|
|
@@ -72,6 +72,7 @@ module ArtiMark
|
|
72
72
|
if !@pages.last.frozen?
|
73
73
|
end_html
|
74
74
|
end
|
75
|
+
|
75
76
|
@pages
|
76
77
|
end
|
77
78
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ArtiMark
|
2
|
+
class Context
|
3
|
+
class Result < Array
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def write_as_files(prefix, format='%03d')
|
9
|
+
self.each_with_index {
|
10
|
+
|converted, i|
|
11
|
+
File.open("#{prefix}_#{format%(i+1)}.xhtml", 'w+') {
|
12
|
+
|file|
|
13
|
+
file << converted
|
14
|
+
}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
def write_as_single_file(filename)
|
18
|
+
File.open(filename, 'w+') {
|
19
|
+
|file|
|
20
|
+
file << self[0]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/arti_mark/version.rb
CHANGED
data/lib/arti_mark.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arti_mark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta1
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -69,13 +69,12 @@ files:
|
|
69
69
|
- lib/arti_mark/list_parser.rb
|
70
70
|
- lib/arti_mark/ordered_list_parser.rb
|
71
71
|
- lib/arti_mark/paragraph_parser.rb
|
72
|
-
- lib/arti_mark/
|
72
|
+
- lib/arti_mark/result.rb
|
73
73
|
- lib/arti_mark/section_parser.rb
|
74
74
|
- lib/arti_mark/syntax.rb
|
75
75
|
- lib/arti_mark/universal_block_parser.rb
|
76
76
|
- lib/arti_mark/unordered_list_parser.rb
|
77
77
|
- lib/arti_mark/version.rb
|
78
|
-
- memo.txt
|
79
78
|
- spec/arti_mark_spec.rb
|
80
79
|
- spec/fixture/test_src_ja.arti
|
81
80
|
- spec/nokogiri_test_helper.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module ArtiMark
|
2
|
-
class Context
|
3
|
-
attr_accessor :title, :head_inserters, :toc
|
4
|
-
def initialize(param = {})
|
5
|
-
@head_inserters = []
|
6
|
-
@toc = []
|
7
|
-
@lang = param[:lang] || 'en'
|
8
|
-
@title = param[:title] || 'ArtiMark generated document'
|
9
|
-
@stylesheets = param[:stylesheets] || []
|
10
|
-
@stylesheets_alt = param[:stylesheets_alt] || []
|
11
|
-
@pages = []
|
12
|
-
head_inserter do
|
13
|
-
ret = ""
|
14
|
-
@stylesheets.each { |s|
|
15
|
-
ret << "<link rel=\"stylesheet\" type=\"text/css\" href=\"#{s}\" />\n"
|
16
|
-
}
|
17
|
-
@stylesheets_alt.each { |s,m|
|
18
|
-
ret << "<link rel=\"stylesheet\" type=\"text/css\" media = \"#{m}\" href=\"#{s}\" />\n"
|
19
|
-
}
|
20
|
-
ret
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def head_inserter(&block)
|
25
|
-
head_inserters << block
|
26
|
-
end
|
27
|
-
|
28
|
-
def start_html(title = nil)
|
29
|
-
@title = title if !title.nil?
|
30
|
-
if @pages.size >0 && !@pages.last.frozen?
|
31
|
-
end_html
|
32
|
-
end
|
33
|
-
page = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
34
|
-
page << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"#{@lang}\" xml:lang=\"#{@lang}\">\n"
|
35
|
-
page << "<head>\n"
|
36
|
-
page << "<title>#{@title}</title>\n"
|
37
|
-
@head_inserters.each {
|
38
|
-
|f|
|
39
|
-
page << f.call
|
40
|
-
}
|
41
|
-
page << "</head>\n"
|
42
|
-
page << "<body>\n"
|
43
|
-
@pages << page
|
44
|
-
@toc << title
|
45
|
-
end
|
46
|
-
|
47
|
-
def end_html
|
48
|
-
page = @pages.last
|
49
|
-
if !page.frozen?
|
50
|
-
page << "</body>\n"
|
51
|
-
page << "</html>\n"
|
52
|
-
page.freeze
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def toc=(label)
|
57
|
-
@toc[-1] = label if @toc.size > 0
|
58
|
-
end
|
59
|
-
|
60
|
-
def <<(text)
|
61
|
-
if @pages.size == 0 || @pages.last.frozen?
|
62
|
-
start_html
|
63
|
-
end
|
64
|
-
@pages.last << text
|
65
|
-
end
|
66
|
-
|
67
|
-
def result
|
68
|
-
if !@pages.last.frozen?
|
69
|
-
end_html
|
70
|
-
end
|
71
|
-
@pages
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
data/memo.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
「blockを取り出してパースする」
|
2
|
-
のではなく、
|
3
|
-
「blockの先頭を認識したら、そのblockを処理するオブジェクトに処理をまかせる」
|
4
|
-
|
5
|
-
blockの処理
|
6
|
-
|
7
|
-
lineを取り出す
|
8
|
-
blockのend条件をチェック
|
9
|
-
endじゃなければ処理
|
10
|
-
endなら終了
|
11
|
-
|
12
|
-
end条件チェック:
|
13
|
-
paragraph: 他のブロック開始
|
14
|
-
ol/ul : リスト条件の終了
|
15
|
-
その他のブロック: 終端記号
|
16
|
-
|
17
|
-
処理:
|
18
|
-
a. 他のブロック開始: ブロックパーサ起動
|
19
|
-
b. 通常のライン: ラインとして処理
|
20
|
-
c. 特殊処理 (ol/ul)
|
21
|
-
|
22
|
-
b/cについては、preがなければインラインコマンドを処理する。
|