ppz 0.0.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/doc/index.rb +9 -0
  3. data/lib/{model → doc/model}/abstract/model.rb +0 -0
  4. data/lib/{model → doc/model}/abstract/wrapper-model.rb +0 -0
  5. data/lib/{model → doc/model}/comment/container.rb +0 -0
  6. data/lib/{model → doc/model}/comment/item.rb +0 -0
  7. data/lib/{model → doc/model}/common/escape.rb +0 -0
  8. data/lib/{model → doc/model}/common/tag.rb +0 -0
  9. data/lib/doc/model/index.rb +17 -0
  10. data/lib/{model → doc/model}/list/item/abstract.rb +0 -0
  11. data/lib/{model → doc/model}/list/item/unordered.rb +0 -0
  12. data/lib/{model → doc/model}/list/wrapper/abstract.rb +0 -0
  13. data/lib/{model → doc/model}/list/wrapper/unordered.rb +0 -0
  14. data/lib/{model → doc/model}/p/index.rb +0 -0
  15. data/lib/{model → doc/model}/section/abstract.rb +0 -0
  16. data/lib/{model → doc/model}/section/leaf.rb +0 -0
  17. data/lib/{model → doc/model}/section/root.rb +0 -0
  18. data/lib/{model → doc/model}/special-block/container.rb +0 -0
  19. data/lib/{model → doc/model}/special-block/item.rb +0 -0
  20. data/lib/{parser/doc → doc/parser}/abstract.rb +1 -1
  21. data/lib/{parser/common/context/doc.rb → doc/parser/context.rb} +28 -1
  22. data/lib/{parser/doc → doc/parser}/file.rb +0 -0
  23. data/lib/{parser/doc → doc/parser}/string.rb +0 -0
  24. data/lib/{parser/folder → folder}/index.rb +0 -0
  25. data/lib/{parser/folder → folder}/model/abstract.rb +6 -6
  26. data/lib/{parser/folder → folder}/model/file/abstract.rb +0 -0
  27. data/lib/{parser/folder → folder}/model/file/other.rb +0 -0
  28. data/lib/{parser/folder → folder}/model/file/ppz.rb +0 -0
  29. data/lib/{parser/folder → folder}/model/folder.rb +18 -10
  30. data/lib/ppz.rb +2 -23
  31. metadata +32 -38
  32. data/asset/style/ppz.css +0 -141
  33. data/asset/style/ppz.styl +0 -126
  34. data/bin/common.rb +0 -42
  35. data/bin/doc.rb +0 -17
  36. data/bin/folder.rb +0 -10
  37. data/bin/ppz +0 -14
  38. data/lib/parser/common/context/abstract.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bad1dbe093ab8a51881656c02401cfbefce4f3ca153a5dfc7b5f9cd5483a161c
4
- data.tar.gz: 02a01ac4f61ef0e2edd725407ecf1baed235501b635065463049db698a2719d9
3
+ metadata.gz: d446dbd5570e54876363303e60e7d6b42c74074b231a62a7cd418fa4c241b768
4
+ data.tar.gz: cf6870884a629d64224f256ffe0c7e4620d525e1d1fa1fe7f7739a691981984a
5
5
  SHA512:
6
- metadata.gz: 72f1066915ce586d43b514411d109c7016b754b30cfb192262044813d8db268ca14c99226edadd8bfd5f627f0ef48d96d8ca9337fdb6f7f13e33a10f8c5a67a9
7
- data.tar.gz: 8e7267e62274f2ff85c89596ab7799a64574fba03da5c776f3293b0e39da4aeebba208b989b04756bb98304a58abb967a0317455a3533e04411917109af318c7
6
+ metadata.gz: 9b5e40c14d3e4b916a35fbb27691b31d1dff0bda542d09fabbc53b764addd59251e47986e09371a5ac9d1046a0612e783ce7e435b2596019da944c436a0a5104
7
+ data.tar.gz: 572592413bf31f57f23c32d797bc716a849aa1132d0010924d05ea0955fe466e1227c1d977467130f440a0237cc144211573632f9c793301dbf5da15e261ca69
data/lib/doc/index.rb ADDED
@@ -0,0 +1,9 @@
1
+ module PPZ
2
+ # model
3
+ require_relative './model/index'
4
+ # parser
5
+ require_relative './parser/context'
6
+ require_relative './parser/abstract'
7
+ require_relative './parser/file'
8
+ require_relative './parser/string'
9
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ module PPZ
2
+ require_relative './abstract/model'
3
+ require_relative './abstract/wrapper-model'
4
+ require_relative './section/abstract'
5
+ require_relative './section/leaf'
6
+ require_relative './section/root'
7
+ require_relative './comment/container'
8
+ require_relative './comment/item'
9
+ require_relative './common/escape'
10
+ require_relative './list/wrapper/abstract'
11
+ require_relative './list/wrapper/unordered'
12
+ require_relative './list/item/abstract'
13
+ require_relative './list/item/unordered'
14
+ require_relative './p/index'
15
+ require_relative './special-block/container'
16
+ require_relative './special-block/item'
17
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  class PPZ::AbstractDocParser
4
4
  def initialize
5
- @context = PPZ::DocContext.new PPZ::RootSectionModel.new
5
+ @context = PPZ::ParserContext.new PPZ::RootSectionModel.new
6
6
  end
7
7
 
8
8
  def get_model
@@ -1,4 +1,11 @@
1
- class PPZ::DocContext < PPZ::AbstractContext
1
+ # 当前行,所处的上下文
2
+ # 比如 一级 section 下面的 ul 下的 第 n 个 ul
3
+
4
+ class PPZ::ParserContext
5
+ def initialize root
6
+ @stack = [root]
7
+ end
8
+
2
9
  def append target
3
10
  # ContainerClass: 容器类,如果上级不是,就造一个
4
11
  if(PPZ::Func::class_has_const? target, :ContainerClass) and (head.class != target.class::ContainerClass)
@@ -12,4 +19,24 @@ class PPZ::DocContext < PPZ::AbstractContext
12
19
  head.append target # 加入 model
13
20
  @stack.push target if target.is_a? PPZ::AbstractWrapperModel # 加入 stack
14
21
  end
22
+
23
+ def pop
24
+ @stack.pop
25
+ end
26
+
27
+ def head
28
+ @stack[-1]
29
+ end
30
+
31
+ def root
32
+ @stack[0]
33
+ end
34
+
35
+ private
36
+ def pop_to klass
37
+ loop do
38
+ break if head.is_a? klass
39
+ pop
40
+ end
41
+ end
15
42
  end
File without changes
File without changes
File without changes
@@ -26,13 +26,13 @@ module PPZ::Folder
26
26
  end
27
27
 
28
28
  def relative_link target
29
- relative_level = target.level - @level # relative_level 是“当前 model 比目标 level 高几级”
29
+ relative_level = @level - target.level # relative_level 是“目标 model 比当前 level 高几级”
30
30
 
31
31
  (if relative_level > 0
32
32
  '../' * relative_level
33
33
  elsif relative_level < 0
34
34
  result = ''
35
- father = @father_model
35
+ father = target.father_model
36
36
  (- relative_level).times do
37
37
  result = father.name + '/' + result
38
38
  father = father.father_model
@@ -40,7 +40,7 @@ module PPZ::Folder
40
40
  result
41
41
  else
42
42
  ''
43
- end) + @name + '.html'
43
+ end) + target.name + '.html'
44
44
  end
45
45
 
46
46
  private
@@ -65,7 +65,7 @@ module PPZ::Folder
65
65
  end
66
66
  %~<div class="ancestor-nav"><ul>#{
67
67
  (list.collect do |node|
68
- %`<li><a href="#{node.relative_link self}">#{node.name}</a></li>`
68
+ %`<li><a href="#{relative_link node}">#{node.name}</a></li>`
69
69
  end
70
70
  .join) + %`<li class="self">#{self.name}</li>`
71
71
  }</ul></div>~
@@ -75,12 +75,12 @@ module PPZ::Folder
75
75
  # prev_model nav_html
76
76
  prev_model_html = ''
77
77
  if @prev_model
78
- prev_link = @prev_model.relative_link self
78
+ prev_link = relative_link @prev_model
79
79
  prev_model_html = "<li class=\"prev\"><a href=\"#{prev_link}\">#{@prev_model.name}</a></li>"
80
80
  end
81
81
  next_model_html = ''
82
82
  if @next_model
83
- next_link = @next_model.relative_link self
83
+ next_link = relative_link @next_model
84
84
  next_model_html = "<li class=\"next\"><a href=\"#{next_link}\">#{@next_model.name}</a></li>"
85
85
  end
86
86
 
File without changes
File without changes
@@ -54,6 +54,23 @@ module PPZ::Folder
54
54
  end
55
55
  end
56
56
 
57
+ def get_content_table_html root
58
+ %~<ul>#{
59
+ @children
60
+ .select do |child|
61
+ (child.class == FolderModel) || (child.file_ext == '.ppz')
62
+ end
63
+ .map do |child|
64
+ result = "<li><a href=\"./#{root.relative_link child}\">#{child.name}</a></li>"
65
+ if child.is_a? FolderModel
66
+ result += child.get_content_table_html root
67
+ end
68
+ result
69
+ end
70
+ .join
71
+ }</ul>~
72
+ end
73
+
57
74
  # 设置页面的“上一篇、下一篇”
58
75
  private
59
76
  def set_prev_and_next_page
@@ -78,16 +95,7 @@ module PPZ::Folder
78
95
  end
79
96
 
80
97
  def get_content_html
81
- %!<article><ul>#{
82
- @children
83
- .select do |child|
84
- (child.class == FolderModel) || (child.file_ext == '.ppz')
85
- end
86
- .map do |child|
87
- "<li><a href=\"./#{@name}/#{child.name}.html\">#{child.name}</a></li>"
88
- end
89
- .join
90
- }</ul></article>!
98
+ "<article>#{get_content_table_html self}</article>"
91
99
  end
92
100
  end
93
101
  end
data/lib/ppz.rb CHANGED
@@ -1,26 +1,5 @@
1
1
  module PPZ
2
2
  require_relative './func/util'
3
-
4
- require_relative './model/abstract/model'
5
- require_relative './model/abstract/wrapper-model'
6
- require_relative './model/section/abstract'
7
- require_relative './model/section/leaf'
8
- require_relative './model/section/root'
9
- require_relative './model/comment/container'
10
- require_relative './model/comment/item'
11
- require_relative './model/common/escape'
12
- require_relative './model/list/wrapper/abstract'
13
- require_relative './model/list/wrapper/unordered'
14
- require_relative './model/list/item/abstract'
15
- require_relative './model/list/item/unordered'
16
- require_relative './model/p/index'
17
- require_relative './model/special-block/container'
18
- require_relative './model/special-block/item'
19
-
20
- require_relative './parser/common/context/abstract'
21
- require_relative './parser/common/context/doc'
22
- require_relative './parser/doc/abstract'
23
- require_relative './parser/doc/file'
24
- require_relative './parser/doc/string'
25
-
3
+ require_relative './doc/index'
4
+ require_relative './folder/index'
26
5
  end
metadata CHANGED
@@ -1,56 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - wuse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-20 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: 372301467@qq.com
15
- executables:
16
- - ppz
15
+ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - asset/style/ppz.css
21
- - asset/style/ppz.styl
22
- - bin/common.rb
23
- - bin/doc.rb
24
- - bin/folder.rb
25
- - bin/ppz
19
+ - lib/doc/index.rb
20
+ - lib/doc/model/abstract/model.rb
21
+ - lib/doc/model/abstract/wrapper-model.rb
22
+ - lib/doc/model/comment/container.rb
23
+ - lib/doc/model/comment/item.rb
24
+ - lib/doc/model/common/escape.rb
25
+ - lib/doc/model/common/tag.rb
26
+ - lib/doc/model/index.rb
27
+ - lib/doc/model/list/item/abstract.rb
28
+ - lib/doc/model/list/item/unordered.rb
29
+ - lib/doc/model/list/wrapper/abstract.rb
30
+ - lib/doc/model/list/wrapper/unordered.rb
31
+ - lib/doc/model/p/index.rb
32
+ - lib/doc/model/section/abstract.rb
33
+ - lib/doc/model/section/leaf.rb
34
+ - lib/doc/model/section/root.rb
35
+ - lib/doc/model/special-block/container.rb
36
+ - lib/doc/model/special-block/item.rb
37
+ - lib/doc/parser/abstract.rb
38
+ - lib/doc/parser/context.rb
39
+ - lib/doc/parser/file.rb
40
+ - lib/doc/parser/string.rb
41
+ - lib/folder/index.rb
42
+ - lib/folder/model/abstract.rb
43
+ - lib/folder/model/file/abstract.rb
44
+ - lib/folder/model/file/other.rb
45
+ - lib/folder/model/file/ppz.rb
46
+ - lib/folder/model/folder.rb
26
47
  - lib/func/util.rb
27
- - lib/model/abstract/model.rb
28
- - lib/model/abstract/wrapper-model.rb
29
- - lib/model/comment/container.rb
30
- - lib/model/comment/item.rb
31
- - lib/model/common/escape.rb
32
- - lib/model/common/tag.rb
33
- - lib/model/list/item/abstract.rb
34
- - lib/model/list/item/unordered.rb
35
- - lib/model/list/wrapper/abstract.rb
36
- - lib/model/list/wrapper/unordered.rb
37
- - lib/model/p/index.rb
38
- - lib/model/section/abstract.rb
39
- - lib/model/section/leaf.rb
40
- - lib/model/section/root.rb
41
- - lib/model/special-block/container.rb
42
- - lib/model/special-block/item.rb
43
- - lib/parser/common/context/abstract.rb
44
- - lib/parser/common/context/doc.rb
45
- - lib/parser/doc/abstract.rb
46
- - lib/parser/doc/file.rb
47
- - lib/parser/doc/string.rb
48
- - lib/parser/folder/index.rb
49
- - lib/parser/folder/model/abstract.rb
50
- - lib/parser/folder/model/file/abstract.rb
51
- - lib/parser/folder/model/file/other.rb
52
- - lib/parser/folder/model/file/ppz.rb
53
- - lib/parser/folder/model/folder.rb
54
48
  - lib/ppz.rb
55
49
  homepage: https://github.com/daGaiGuanYu/ppz
56
50
  licenses:
@@ -74,5 +68,5 @@ requirements: []
74
68
  rubygems_version: 3.1.4
75
69
  signing_key:
76
70
  specification_version: 4
77
- summary: 写作
71
+ summary: compile ppz to html
78
72
  test_files: []
data/asset/style/ppz.css DELETED
@@ -1,141 +0,0 @@
1
- html {
2
- line-height: 1.5;
3
- }
4
- body,
5
- div,
6
- p,
7
- aside {
8
- box-sizing: border-box;
9
- }
10
- body {
11
- margin: 0;
12
- padding: 0;
13
- position: relative;
14
- }
15
- aside {
16
- overflow-y: auto;
17
- padding: 2rem 1rem;
18
- position: fixed;
19
- top: 0;
20
- left: 0;
21
- width: 188px;
22
- height: 100vh;
23
- }
24
- aside ul {
25
- margin: 0 0 0 1rem;
26
- padding: 0;
27
- list-style: none;
28
- }
29
- aside a {
30
- width: 100%;
31
- display: block;
32
- overflow: hidden;
33
- text-overflow: ellipsis;
34
- white-space: nowrap;
35
- }
36
- .ancestor-nav ul {
37
- margin: 0;
38
- padding: 0;
39
- list-style: none;
40
- font-size: 0.8rem;
41
- margin: 1rem 2rem 0 0;
42
- text-align: right;
43
- }
44
- .ancestor-nav li {
45
- margin: 0;
46
- padding: 0;
47
- display: inline-block;
48
- }
49
- .ancestor-nav li a {
50
- display: inline-block;
51
- opacity: 0.66;
52
- transition: all 0.3s;
53
- }
54
- .ancestor-nav li a:hover {
55
- opacity: 1;
56
- transform: scale(1.1, 1.1);
57
- }
58
- .ancestor-nav li:not(.self)::after {
59
- content: '/';
60
- margin: 0 0.36rem;
61
- }
62
- article {
63
- margin-left: 188px;
64
- padding: 1px 2rem 1rem 1rem;
65
- }
66
- h1 {
67
- font-size: 2rem;
68
- }
69
- h2 {
70
- font-size: 1.3rem;
71
- }
72
- h3 {
73
- font-size: 1.1rem;
74
- opacity: 0.9;
75
- }
76
- h1::before,
77
- h2::before,
78
- h3::before {
79
- content: '# ';
80
- opacity: 0.3;
81
- font-size: 1rem;
82
- }
83
- .comment-container {
84
- margin: 1rem 0;
85
- padding: 1rem 1.6rem;
86
- background: rgba(0,0,0,0.2);
87
- font-size: 0.9rem;
88
- border-radius: 4px;
89
- }
90
- .comment-item {
91
- opacity: 0.8;
92
- }
93
- .special-block-container {
94
- background: #141c22;
95
- overflow: auto;
96
- border-radius: 4px;
97
- color: #eee;
98
- font-family: monospace;
99
- white-space: pre;
100
- margin: 1rem 0;
101
- padding: 1rem;
102
- counter-reset: line-index;
103
- }
104
- .special-block-item::before {
105
- counter-increment: line-index;
106
- content: counter(line-index) " | ";
107
- opacity: 0.3;
108
- }
109
- .special-block-item:hover::before {
110
- opacity: 0.8;
111
- }
112
- .special-txt {
113
- background: rgba(27,31,35,0.05);
114
- border-radius: 4px;
115
- font-size: 0.9em;
116
- padding: 2px 4px;
117
- }
118
- .interpage-nav {
119
- margin: 1rem 2rem 2rem 188px;
120
- padding: 0 2rem;
121
- list-style: none;
122
- }
123
- .interpage-nav .prev {
124
- float: left;
125
- }
126
- .interpage-nav .prev::before {
127
- content: '上一篇:';
128
- opacity: 0.6;
129
- }
130
- .interpage-nav .next {
131
- float: right;
132
- }
133
- .interpage-nav .next::before {
134
- content: '下一篇:';
135
- opacity: 0.6;
136
- }
137
- .interpage-nav::after {
138
- content: '';
139
- display: block;
140
- clear: both;
141
- }
data/asset/style/ppz.styl DELETED
@@ -1,126 +0,0 @@
1
- nav-width = 188px
2
-
3
- html
4
- line-height 1.5
5
- body, div, p, aside
6
- box-sizing border-box
7
-
8
- body
9
- margin 0
10
- padding 0
11
- position relative
12
-
13
- aside
14
- overflow-y auto
15
- padding: 2rem 1rem;
16
-
17
- position fixed
18
- top 0
19
- left 0
20
- width nav-width
21
- height 100vh
22
-
23
- ul
24
- margin 0 0 0 1rem
25
- padding 0
26
- list-style none
27
- a
28
- width 100%
29
- display block
30
- overflow hidden
31
- text-overflow ellipsis
32
- white-space nowrap
33
- .ancestor-nav
34
- ul
35
- margin 0
36
- padding 0
37
- list-style none
38
- font-size 0.8rem
39
- margin 1rem 2rem 0 0
40
- text-align right
41
- li
42
- margin 0
43
- padding 0
44
- display inline-block
45
- a
46
- display inline-block
47
- opacity 0.66
48
- transition all 0.3s
49
- &:hover
50
- opacity 1
51
- transform scale(1.1, 1.1)
52
- &:not(.self)::after
53
- content '/'
54
- margin 0 .36rem
55
-
56
- article
57
- margin-left nav-width
58
- padding: 1px 2rem 1rem 1rem
59
- h1
60
- font-size 2rem
61
- h2
62
- font-size 1.3rem
63
- h3
64
- font-size 1.1rem
65
- opacity 0.9
66
-
67
- h1, h2, h3
68
- &::before
69
- content '# '
70
- opacity 0.3
71
- font-size 1rem
72
-
73
- .comment-container
74
- margin 1rem 0
75
- padding 1rem 1.6rem
76
- background rgba(0, 0, 0, 0.2)
77
- font-size 0.9rem
78
- border-radius 4px
79
- .comment-item
80
- opacity 0.8
81
-
82
- .special-block-container
83
- background #141c22
84
- overflow auto
85
- border-radius 4px
86
- color #eeeeee
87
-
88
- font-family monospace
89
- white-space pre
90
-
91
- margin 1rem 0
92
- padding 1rem
93
-
94
- counter-reset line-index
95
- .special-block-item
96
- &::before
97
- counter-increment line-index
98
- content counter(line-index) " | "
99
- opacity 0.3
100
- &:hover::before
101
- opacity 0.8
102
-
103
- .special-txt
104
- background rgba(27, 31, 35, 0.05)
105
- border-radius 4px
106
- font-size 0.9em
107
- padding 2px 4px
108
-
109
- .interpage-nav
110
- margin 1rem 2rem 2rem nav-width
111
- padding 0 2rem
112
- list-style none
113
- .prev
114
- float left
115
- &::before
116
- content '上一篇:'
117
- opacity 0.6
118
- .next
119
- float right
120
- &::before
121
- content '下一篇:'
122
- opacity 0.6
123
- &::after
124
- content ''
125
- display block
126
- clear both
data/bin/common.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'pathname'
2
-
3
- module PPZMain
4
- CURRENT_PATH = File.dirname __FILE__
5
- CSS_FILE_PATH = (Pathname CURRENT_PATH) + '../asset/style/ppz.css'
6
-
7
- class Util
8
- class << self
9
- def get_in_and_out
10
- target_in, target_out = ARGV
11
-
12
- # 输入文件
13
- abort '要编译哪那个文件?请告诉我' unless target_in # 检查参数存在
14
- target_in = PPZ::Func.format_path target_in
15
- unless File.exist? target_in # 不存在的话,看看加上 .ppz 后是否存在
16
- target_in += '.ppz'
17
- abort target_in[0..-5] + ' 不存在' unless File.exist? target_in # 还不存在的话,就说明是写错了
18
- end
19
- is_folder = File.directory? target_in
20
-
21
- # 输出文件
22
- unless target_out
23
- # 从输入文件获取文件名
24
- target_out = ((/(.*).ppz$/.match target_in)?$1:target_in) + '.pp'
25
- end
26
- # + 检查上级文件夹是否存在
27
- upper_dir = ((Pathname target_out) + '..').to_s
28
- abort upper_dir + ' 目录不存在' unless Dir.exist? upper_dir
29
- # + 检查文件夹:有则检查里面有没有文件;无则创建文件夹
30
- target_out = target_out.to_s
31
- if Dir.exist? target_out
32
- abort target_out + ' 不是一个空文件夹' unless (Dir.children target_out).size == 0
33
- else
34
- Dir.mkdir target_out
35
- end
36
- target_out = PPZ::Func.format_path target_out
37
-
38
- [target_in, target_out, is_folder]
39
- end
40
- end
41
- end
42
- end
data/bin/doc.rb DELETED
@@ -1,17 +0,0 @@
1
- target_out = Pathname TARGET_OUT
2
-
3
- # css
4
- # 输出文件路径
5
- output_css_path = target_out + 'index.css'
6
- # 复制
7
- FileUtils.cp PPZMain::CSS_FILE_PATH, output_css_path
8
-
9
- # html
10
- # 输出文件路径
11
- output_html_path = target_out + 'index.html'
12
- # 解析文档
13
- parser = PPZ::FileDocParser.new TARGET_IN
14
- # 拼接上 css 文件链接
15
- output_html = '<link rel="stylesheet" href="./index.css"/>' + parser.get_model.to_html
16
- # 输出
17
- PPZ::Func::write_to_file output_html_path.to_s, output_html
data/bin/folder.rb DELETED
@@ -1,10 +0,0 @@
1
- require_relative '../lib/parser/folder/index'
2
-
3
- puts '输入文件夹: ' + TARGET_IN
4
- puts '输出文件夹: ' + TARGET_OUT
5
- puts
6
-
7
- FileUtils.cp PPZMain::CSS_FILE_PATH, ((Pathname TARGET_OUT) + 'style.css').to_s
8
-
9
- model = PPZ::Folder::FolderModel.new TARGET_IN, 0
10
- model.compile TARGET_OUT
data/bin/ppz DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/ppz'
4
- require_relative './common'
5
- require 'fileutils'
6
- require 'pathname'
7
-
8
- TARGET_IN, TARGET_OUT, IS_FOLDER = PPZMain::Util.get_in_and_out
9
-
10
- if IS_FOLDER
11
- require_relative './folder.rb'
12
- else
13
- require_relative './doc.rb'
14
- end
@@ -1,30 +0,0 @@
1
- # 当前行,所处的上下文
2
- # 比如 一级 section 下面的 ul 下的 第 n 个 ul
3
-
4
- class PPZ::AbstractContext
5
- def initialize root
6
- @stack = [root]
7
- end
8
-
9
- # def append # 交给子类实现
10
-
11
- def pop
12
- @stack.pop
13
- end
14
-
15
- def head
16
- @stack[-1]
17
- end
18
-
19
- def root
20
- @stack[0]
21
- end
22
-
23
- private
24
- def pop_to klass
25
- loop do
26
- break if head.is_a? klass
27
- pop
28
- end
29
- end
30
- end