Almirah 0.2.5 → 0.2.6
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.
- checksums.yaml +4 -4
- data/bin/almirah +4 -4
- data/lib/almirah/doc_fabric.rb +65 -65
- data/lib/almirah/doc_items/blockquote.rb +21 -21
- data/lib/almirah/doc_items/code_block.rb +26 -26
- data/lib/almirah/doc_items/controlled_paragraph.rb +112 -112
- data/lib/almirah/doc_items/controlled_table.rb +224 -224
- data/lib/almirah/doc_items/controlled_table_row.rb +22 -22
- data/lib/almirah/doc_items/doc_footer.rb +16 -16
- data/lib/almirah/doc_items/doc_item.rb +22 -22
- data/lib/almirah/doc_items/frontmatter.rb +9 -9
- data/lib/almirah/doc_items/heading.rb +93 -93
- data/lib/almirah/doc_items/image.rb +27 -27
- data/lib/almirah/doc_items/markdown_list.rb +156 -156
- data/lib/almirah/doc_items/markdown_table.rb +61 -61
- data/lib/almirah/doc_items/paragraph.rb +25 -25
- data/lib/almirah/doc_items/text_line.rb +296 -296
- data/lib/almirah/doc_items/todo_block.rb +21 -21
- data/lib/almirah/doc_parser.rb +378 -378
- data/lib/almirah/doc_types/base_document.rb +64 -64
- data/lib/almirah/doc_types/coverage.rb +95 -80
- data/lib/almirah/doc_types/index.rb +173 -173
- data/lib/almirah/doc_types/persistent_document.rb +17 -17
- data/lib/almirah/doc_types/protocol.rb +24 -24
- data/lib/almirah/doc_types/specification.rb +67 -67
- data/lib/almirah/doc_types/traceability.rb +142 -142
- data/lib/almirah/dom/doc_section.rb +25 -25
- data/lib/almirah/dom/document.rb +78 -78
- data/lib/almirah/navigation_pane.rb +16 -16
- data/lib/almirah/project.rb +287 -287
- data/lib/almirah/project_configuration.rb +41 -41
- data/lib/almirah/project_template.rb +298 -298
- data/lib/almirah/project_utility.rb +52 -0
- data/lib/almirah/search/specifications_db.rb +79 -79
- data/lib/almirah/templates/css/main.css +300 -300
- data/lib/almirah/templates/css/search.css +40 -40
- data/lib/almirah/templates/page.html +42 -42
- data/lib/almirah/templates/scripts/main.js +111 -111
- data/lib/almirah/templates/scripts/orama_search.js +138 -138
- data/lib/almirah.rb +93 -58
- metadata +4 -3
@@ -1,25 +1,25 @@
|
|
1
|
-
require_relative 'doc_item'
|
2
|
-
|
3
|
-
class Paragraph < DocItem
|
4
|
-
attr_accessor :text
|
5
|
-
|
6
|
-
def initialize(doc, text)
|
7
|
-
super(doc)
|
8
|
-
@text = text.strip
|
9
|
-
end
|
10
|
-
|
11
|
-
def getTextWithoutSpaces
|
12
|
-
@text.split.join('-').downcase
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_html
|
16
|
-
s = ''
|
17
|
-
if @@html_table_render_in_progress
|
18
|
-
s += '</table>'
|
19
|
-
@@html_table_render_in_progress = false
|
20
|
-
end
|
21
|
-
|
22
|
-
s += "<p>#{format_string(@text)}"
|
23
|
-
s
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require_relative 'doc_item'
|
2
|
+
|
3
|
+
class Paragraph < DocItem
|
4
|
+
attr_accessor :text
|
5
|
+
|
6
|
+
def initialize(doc, text)
|
7
|
+
super(doc)
|
8
|
+
@text = text.strip
|
9
|
+
end
|
10
|
+
|
11
|
+
def getTextWithoutSpaces
|
12
|
+
@text.split.join('-').downcase
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_html
|
16
|
+
s = ''
|
17
|
+
if @@html_table_render_in_progress
|
18
|
+
s += '</table>'
|
19
|
+
@@html_table_render_in_progress = false
|
20
|
+
end
|
21
|
+
|
22
|
+
s += "<p>#{format_string(@text)}"
|
23
|
+
s
|
24
|
+
end
|
25
|
+
end
|
@@ -1,296 +1,296 @@
|
|
1
|
-
class TextLineToken
|
2
|
-
attr_accessor :value
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@value = ''
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class ItalicToken < TextLineToken
|
10
|
-
def initialize # rubocop:disable Lint/MissingSuper
|
11
|
-
@value = '*'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class BoldToken < TextLineToken
|
16
|
-
def initialize # rubocop:disable Lint/MissingSuper
|
17
|
-
@value = '**'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class BoldAndItalicToken < TextLineToken
|
22
|
-
def initialize # rubocop:disable Lint/MissingSuper
|
23
|
-
@value = '***'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class ParentheseLeft < TextLineToken
|
28
|
-
def initialize # rubocop:disable Lint/MissingSuper
|
29
|
-
@value = '('
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class ParentheseRight < TextLineToken
|
34
|
-
def initialize
|
35
|
-
@value = ')'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class SquareBracketLeft < TextLineToken
|
40
|
-
def initialize # rubocop:disable Lint/MissingSuper
|
41
|
-
@value = '['
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class SquareBracketRight < TextLineToken
|
46
|
-
def initialize
|
47
|
-
@value = ']'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class SquareBracketRightAndParentheseLeft < TextLineToken
|
52
|
-
def initialize
|
53
|
-
@value = ']('
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class TextLineParser
|
58
|
-
attr_accessor :supported_tokens
|
59
|
-
|
60
|
-
def initialize # rubocop:disable Metrics/AbcSize
|
61
|
-
@supported_tokens = []
|
62
|
-
@supported_tokens.append(BoldAndItalicToken.new)
|
63
|
-
@supported_tokens.append(BoldToken.new)
|
64
|
-
@supported_tokens.append(ItalicToken.new)
|
65
|
-
@supported_tokens.append(SquareBracketRightAndParentheseLeft.new)
|
66
|
-
@supported_tokens.append(ParentheseLeft.new)
|
67
|
-
@supported_tokens.append(ParentheseRight.new)
|
68
|
-
@supported_tokens.append(SquareBracketLeft.new)
|
69
|
-
@supported_tokens.append(SquareBracketRight.new)
|
70
|
-
@supported_tokens.append(TextLineToken.new)
|
71
|
-
end
|
72
|
-
|
73
|
-
def tokenize(str)
|
74
|
-
result = []
|
75
|
-
sl = str.length
|
76
|
-
si = 0
|
77
|
-
while si < sl
|
78
|
-
@supported_tokens.each do |t|
|
79
|
-
tl = t.value.length
|
80
|
-
if tl != 0 # literal is the last supported token in the list
|
81
|
-
projected_end_position = si + tl - 1
|
82
|
-
next if projected_end_position > sl
|
83
|
-
|
84
|
-
buf = str[si..projected_end_position]
|
85
|
-
if buf == t.value
|
86
|
-
result.append(t)
|
87
|
-
si = projected_end_position + 1
|
88
|
-
break
|
89
|
-
end
|
90
|
-
else
|
91
|
-
if result.length.positive? && (result[-1].instance_of? TextLineToken)
|
92
|
-
literal = result[-1]
|
93
|
-
literal.value += str[si]
|
94
|
-
else
|
95
|
-
literal = TextLineToken.new
|
96
|
-
literal.value = str[si]
|
97
|
-
result.append(literal)
|
98
|
-
end
|
99
|
-
si += 1
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
result
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
class TextLineBuilderContext
|
108
|
-
def italic(str)
|
109
|
-
str
|
110
|
-
end
|
111
|
-
|
112
|
-
def bold(str)
|
113
|
-
str
|
114
|
-
end
|
115
|
-
|
116
|
-
def bold_and_italic(str)
|
117
|
-
str
|
118
|
-
end
|
119
|
-
|
120
|
-
def link(_link_text, link_url)
|
121
|
-
link_url
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
class TextLineBuilder
|
126
|
-
attr_accessor :builder_context
|
127
|
-
|
128
|
-
def initialize(builder_context)
|
129
|
-
@builder_context = builder_context
|
130
|
-
end
|
131
|
-
|
132
|
-
def restore(token_list)
|
133
|
-
result = ''
|
134
|
-
return '' if token_list.nil?
|
135
|
-
|
136
|
-
sub_list_url_text = nil
|
137
|
-
sub_list_url_address = nil
|
138
|
-
tl = token_list.length
|
139
|
-
ti = 0
|
140
|
-
while ti < tl
|
141
|
-
case token_list[ti].class.name
|
142
|
-
when 'ItalicToken'
|
143
|
-
is_found = false
|
144
|
-
ti_starting_position = ti
|
145
|
-
# try to find closing part
|
146
|
-
tii = ti + 1
|
147
|
-
while tii < tl
|
148
|
-
if token_list[tii].instance_of? ItalicToken
|
149
|
-
sub_list = token_list[(ti + 1)..(tii - 1)]
|
150
|
-
result += @builder_context.italic(restore(sub_list))
|
151
|
-
ti = tii + 1
|
152
|
-
is_found = true
|
153
|
-
break
|
154
|
-
end
|
155
|
-
tii += 1
|
156
|
-
end
|
157
|
-
unless is_found
|
158
|
-
result += '*'
|
159
|
-
ti = ti_starting_position + 1
|
160
|
-
end
|
161
|
-
when 'BoldToken'
|
162
|
-
is_found = false
|
163
|
-
ti_starting_position = ti
|
164
|
-
# try to find closing part
|
165
|
-
tii = ti + 1
|
166
|
-
while tii < tl
|
167
|
-
if token_list[tii].instance_of? BoldToken
|
168
|
-
sub_list = token_list[(ti + 1)..(tii - 1)]
|
169
|
-
result += @builder_context.bold(restore(sub_list))
|
170
|
-
ti = tii + 1
|
171
|
-
is_found = true
|
172
|
-
break
|
173
|
-
end
|
174
|
-
tii += 1
|
175
|
-
end
|
176
|
-
unless is_found
|
177
|
-
result += '**'
|
178
|
-
ti = ti_starting_position + 1
|
179
|
-
end
|
180
|
-
when 'BoldAndItalicToken'
|
181
|
-
is_found = false
|
182
|
-
ti_starting_position = ti
|
183
|
-
# try to find closing part
|
184
|
-
tii = ti + 1
|
185
|
-
while tii < tl
|
186
|
-
if token_list[tii].instance_of? BoldAndItalicToken
|
187
|
-
sub_list = token_list[(ti + 1)..(tii - 1)]
|
188
|
-
result += @builder_context.bold_and_italic(restore(sub_list))
|
189
|
-
ti = tii + 1
|
190
|
-
is_found = true
|
191
|
-
break
|
192
|
-
end
|
193
|
-
tii += 1
|
194
|
-
end
|
195
|
-
unless is_found
|
196
|
-
result += '***'
|
197
|
-
ti = ti_starting_position + 1
|
198
|
-
end
|
199
|
-
when 'SquareBracketLeft'
|
200
|
-
# try to find closing part
|
201
|
-
is_found = false
|
202
|
-
tii = ti + 1
|
203
|
-
ti_starting_position = ti
|
204
|
-
while tii < tl
|
205
|
-
case token_list[tii].class.name
|
206
|
-
when 'SquareBracketRightAndParentheseLeft'
|
207
|
-
sub_list_url_text = token_list[(ti + 1)..(tii - 1)]
|
208
|
-
ti = tii + 1
|
209
|
-
tiii = ti
|
210
|
-
while tiii < tl
|
211
|
-
case token_list[tiii].class.name
|
212
|
-
when 'ParentheseRight'
|
213
|
-
sub_list_url_address = token_list[(tii + 1)..(tiii - 1)]
|
214
|
-
ti = tiii + 1
|
215
|
-
is_found = true
|
216
|
-
break
|
217
|
-
end
|
218
|
-
tiii += 1
|
219
|
-
end
|
220
|
-
break
|
221
|
-
when 'SquareBracketRight'
|
222
|
-
break
|
223
|
-
end
|
224
|
-
tii += 1
|
225
|
-
end
|
226
|
-
if is_found
|
227
|
-
result += @builder_context.link(restore(sub_list_url_text), restore(sub_list_url_address))
|
228
|
-
else
|
229
|
-
result += '['
|
230
|
-
ti = ti_starting_position + 1
|
231
|
-
end
|
232
|
-
|
233
|
-
when 'TextLineToken', 'ParentheseLeft', 'ParentheseRight', 'SquareBracketRight'
|
234
|
-
result += token_list[ti].value
|
235
|
-
ti += 1
|
236
|
-
else
|
237
|
-
ti += 1
|
238
|
-
end
|
239
|
-
end
|
240
|
-
result
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
class TextLine < TextLineBuilderContext
|
245
|
-
@@lazy_doc_id_dict = {}
|
246
|
-
|
247
|
-
def self.add_lazy_doc_id(id)
|
248
|
-
doc_id = id.to_s.downcase
|
249
|
-
@@lazy_doc_id_dict[doc_id] = doc_id
|
250
|
-
end
|
251
|
-
|
252
|
-
def format_string(str)
|
253
|
-
tlp = TextLineParser.new
|
254
|
-
tlb = TextLineBuilder.new(self)
|
255
|
-
tlb.restore(tlp.tokenize(str))
|
256
|
-
end
|
257
|
-
|
258
|
-
def italic(str)
|
259
|
-
"<i>#{str}</i>"
|
260
|
-
end
|
261
|
-
|
262
|
-
def bold(str)
|
263
|
-
"<b>#{str}</b>"
|
264
|
-
end
|
265
|
-
|
266
|
-
def bold_and_italic(str)
|
267
|
-
"<b><i>#{str}</i></b>"
|
268
|
-
end
|
269
|
-
|
270
|
-
def link(link_text, link_url)
|
271
|
-
# define default result first
|
272
|
-
result = "<a target=\"_blank\" rel=\"noopener\" href=\"#{link_url}\" class=\"external\">#{link_text}</a>"
|
273
|
-
|
274
|
-
lazy_doc_id = nil
|
275
|
-
anchor = nil
|
276
|
-
|
277
|
-
if res = /(\w+)[.]md$/.match(link_url) # link
|
278
|
-
lazy_doc_id = res[1].to_s.downcase
|
279
|
-
|
280
|
-
elsif res = /(\w*)[.]md(#.*)$/.match(link_url) # link with anchor
|
281
|
-
if res && res.length > 2
|
282
|
-
lazy_doc_id = res[1]
|
283
|
-
anchor = res[2]
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
if lazy_doc_id && @@lazy_doc_id_dict.key?(lazy_doc_id)
|
288
|
-
result = if anchor
|
289
|
-
"<a href=\".\\..\\#{lazy_doc_id}\\#{lazy_doc_id}.html#{anchor}\" class=\"external\">#{link_text}</a>"
|
290
|
-
else
|
291
|
-
"<a href=\".\\..\\#{lazy_doc_id}\\#{lazy_doc_id}.html\" class=\"external\">#{link_text}</a>"
|
292
|
-
end
|
293
|
-
end
|
294
|
-
result
|
295
|
-
end
|
296
|
-
end
|
1
|
+
class TextLineToken
|
2
|
+
attr_accessor :value
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@value = ''
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class ItalicToken < TextLineToken
|
10
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
11
|
+
@value = '*'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class BoldToken < TextLineToken
|
16
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
17
|
+
@value = '**'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class BoldAndItalicToken < TextLineToken
|
22
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
23
|
+
@value = '***'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ParentheseLeft < TextLineToken
|
28
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
29
|
+
@value = '('
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class ParentheseRight < TextLineToken
|
34
|
+
def initialize
|
35
|
+
@value = ')'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class SquareBracketLeft < TextLineToken
|
40
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
41
|
+
@value = '['
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class SquareBracketRight < TextLineToken
|
46
|
+
def initialize
|
47
|
+
@value = ']'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class SquareBracketRightAndParentheseLeft < TextLineToken
|
52
|
+
def initialize
|
53
|
+
@value = ']('
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class TextLineParser
|
58
|
+
attr_accessor :supported_tokens
|
59
|
+
|
60
|
+
def initialize # rubocop:disable Metrics/AbcSize
|
61
|
+
@supported_tokens = []
|
62
|
+
@supported_tokens.append(BoldAndItalicToken.new)
|
63
|
+
@supported_tokens.append(BoldToken.new)
|
64
|
+
@supported_tokens.append(ItalicToken.new)
|
65
|
+
@supported_tokens.append(SquareBracketRightAndParentheseLeft.new)
|
66
|
+
@supported_tokens.append(ParentheseLeft.new)
|
67
|
+
@supported_tokens.append(ParentheseRight.new)
|
68
|
+
@supported_tokens.append(SquareBracketLeft.new)
|
69
|
+
@supported_tokens.append(SquareBracketRight.new)
|
70
|
+
@supported_tokens.append(TextLineToken.new)
|
71
|
+
end
|
72
|
+
|
73
|
+
def tokenize(str)
|
74
|
+
result = []
|
75
|
+
sl = str.length
|
76
|
+
si = 0
|
77
|
+
while si < sl
|
78
|
+
@supported_tokens.each do |t|
|
79
|
+
tl = t.value.length
|
80
|
+
if tl != 0 # literal is the last supported token in the list
|
81
|
+
projected_end_position = si + tl - 1
|
82
|
+
next if projected_end_position > sl
|
83
|
+
|
84
|
+
buf = str[si..projected_end_position]
|
85
|
+
if buf == t.value
|
86
|
+
result.append(t)
|
87
|
+
si = projected_end_position + 1
|
88
|
+
break
|
89
|
+
end
|
90
|
+
else
|
91
|
+
if result.length.positive? && (result[-1].instance_of? TextLineToken)
|
92
|
+
literal = result[-1]
|
93
|
+
literal.value += str[si]
|
94
|
+
else
|
95
|
+
literal = TextLineToken.new
|
96
|
+
literal.value = str[si]
|
97
|
+
result.append(literal)
|
98
|
+
end
|
99
|
+
si += 1
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
result
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class TextLineBuilderContext
|
108
|
+
def italic(str)
|
109
|
+
str
|
110
|
+
end
|
111
|
+
|
112
|
+
def bold(str)
|
113
|
+
str
|
114
|
+
end
|
115
|
+
|
116
|
+
def bold_and_italic(str)
|
117
|
+
str
|
118
|
+
end
|
119
|
+
|
120
|
+
def link(_link_text, link_url)
|
121
|
+
link_url
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class TextLineBuilder
|
126
|
+
attr_accessor :builder_context
|
127
|
+
|
128
|
+
def initialize(builder_context)
|
129
|
+
@builder_context = builder_context
|
130
|
+
end
|
131
|
+
|
132
|
+
def restore(token_list)
|
133
|
+
result = ''
|
134
|
+
return '' if token_list.nil?
|
135
|
+
|
136
|
+
sub_list_url_text = nil
|
137
|
+
sub_list_url_address = nil
|
138
|
+
tl = token_list.length
|
139
|
+
ti = 0
|
140
|
+
while ti < tl
|
141
|
+
case token_list[ti].class.name
|
142
|
+
when 'ItalicToken'
|
143
|
+
is_found = false
|
144
|
+
ti_starting_position = ti
|
145
|
+
# try to find closing part
|
146
|
+
tii = ti + 1
|
147
|
+
while tii < tl
|
148
|
+
if token_list[tii].instance_of? ItalicToken
|
149
|
+
sub_list = token_list[(ti + 1)..(tii - 1)]
|
150
|
+
result += @builder_context.italic(restore(sub_list))
|
151
|
+
ti = tii + 1
|
152
|
+
is_found = true
|
153
|
+
break
|
154
|
+
end
|
155
|
+
tii += 1
|
156
|
+
end
|
157
|
+
unless is_found
|
158
|
+
result += '*'
|
159
|
+
ti = ti_starting_position + 1
|
160
|
+
end
|
161
|
+
when 'BoldToken'
|
162
|
+
is_found = false
|
163
|
+
ti_starting_position = ti
|
164
|
+
# try to find closing part
|
165
|
+
tii = ti + 1
|
166
|
+
while tii < tl
|
167
|
+
if token_list[tii].instance_of? BoldToken
|
168
|
+
sub_list = token_list[(ti + 1)..(tii - 1)]
|
169
|
+
result += @builder_context.bold(restore(sub_list))
|
170
|
+
ti = tii + 1
|
171
|
+
is_found = true
|
172
|
+
break
|
173
|
+
end
|
174
|
+
tii += 1
|
175
|
+
end
|
176
|
+
unless is_found
|
177
|
+
result += '**'
|
178
|
+
ti = ti_starting_position + 1
|
179
|
+
end
|
180
|
+
when 'BoldAndItalicToken'
|
181
|
+
is_found = false
|
182
|
+
ti_starting_position = ti
|
183
|
+
# try to find closing part
|
184
|
+
tii = ti + 1
|
185
|
+
while tii < tl
|
186
|
+
if token_list[tii].instance_of? BoldAndItalicToken
|
187
|
+
sub_list = token_list[(ti + 1)..(tii - 1)]
|
188
|
+
result += @builder_context.bold_and_italic(restore(sub_list))
|
189
|
+
ti = tii + 1
|
190
|
+
is_found = true
|
191
|
+
break
|
192
|
+
end
|
193
|
+
tii += 1
|
194
|
+
end
|
195
|
+
unless is_found
|
196
|
+
result += '***'
|
197
|
+
ti = ti_starting_position + 1
|
198
|
+
end
|
199
|
+
when 'SquareBracketLeft'
|
200
|
+
# try to find closing part
|
201
|
+
is_found = false
|
202
|
+
tii = ti + 1
|
203
|
+
ti_starting_position = ti
|
204
|
+
while tii < tl
|
205
|
+
case token_list[tii].class.name
|
206
|
+
when 'SquareBracketRightAndParentheseLeft'
|
207
|
+
sub_list_url_text = token_list[(ti + 1)..(tii - 1)]
|
208
|
+
ti = tii + 1
|
209
|
+
tiii = ti
|
210
|
+
while tiii < tl
|
211
|
+
case token_list[tiii].class.name
|
212
|
+
when 'ParentheseRight'
|
213
|
+
sub_list_url_address = token_list[(tii + 1)..(tiii - 1)]
|
214
|
+
ti = tiii + 1
|
215
|
+
is_found = true
|
216
|
+
break
|
217
|
+
end
|
218
|
+
tiii += 1
|
219
|
+
end
|
220
|
+
break
|
221
|
+
when 'SquareBracketRight'
|
222
|
+
break
|
223
|
+
end
|
224
|
+
tii += 1
|
225
|
+
end
|
226
|
+
if is_found
|
227
|
+
result += @builder_context.link(restore(sub_list_url_text), restore(sub_list_url_address))
|
228
|
+
else
|
229
|
+
result += '['
|
230
|
+
ti = ti_starting_position + 1
|
231
|
+
end
|
232
|
+
|
233
|
+
when 'TextLineToken', 'ParentheseLeft', 'ParentheseRight', 'SquareBracketRight'
|
234
|
+
result += token_list[ti].value
|
235
|
+
ti += 1
|
236
|
+
else
|
237
|
+
ti += 1
|
238
|
+
end
|
239
|
+
end
|
240
|
+
result
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
class TextLine < TextLineBuilderContext
|
245
|
+
@@lazy_doc_id_dict = {}
|
246
|
+
|
247
|
+
def self.add_lazy_doc_id(id)
|
248
|
+
doc_id = id.to_s.downcase
|
249
|
+
@@lazy_doc_id_dict[doc_id] = doc_id
|
250
|
+
end
|
251
|
+
|
252
|
+
def format_string(str)
|
253
|
+
tlp = TextLineParser.new
|
254
|
+
tlb = TextLineBuilder.new(self)
|
255
|
+
tlb.restore(tlp.tokenize(str))
|
256
|
+
end
|
257
|
+
|
258
|
+
def italic(str)
|
259
|
+
"<i>#{str}</i>"
|
260
|
+
end
|
261
|
+
|
262
|
+
def bold(str)
|
263
|
+
"<b>#{str}</b>"
|
264
|
+
end
|
265
|
+
|
266
|
+
def bold_and_italic(str)
|
267
|
+
"<b><i>#{str}</i></b>"
|
268
|
+
end
|
269
|
+
|
270
|
+
def link(link_text, link_url)
|
271
|
+
# define default result first
|
272
|
+
result = "<a target=\"_blank\" rel=\"noopener\" href=\"#{link_url}\" class=\"external\">#{link_text}</a>"
|
273
|
+
|
274
|
+
lazy_doc_id = nil
|
275
|
+
anchor = nil
|
276
|
+
|
277
|
+
if res = /(\w+)[.]md$/.match(link_url) # link
|
278
|
+
lazy_doc_id = res[1].to_s.downcase
|
279
|
+
|
280
|
+
elsif res = /(\w*)[.]md(#.*)$/.match(link_url) # link with anchor
|
281
|
+
if res && res.length > 2
|
282
|
+
lazy_doc_id = res[1]
|
283
|
+
anchor = res[2]
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
if lazy_doc_id && @@lazy_doc_id_dict.key?(lazy_doc_id)
|
288
|
+
result = if anchor
|
289
|
+
"<a href=\".\\..\\#{lazy_doc_id}\\#{lazy_doc_id}.html#{anchor}\" class=\"external\">#{link_text}</a>"
|
290
|
+
else
|
291
|
+
"<a href=\".\\..\\#{lazy_doc_id}\\#{lazy_doc_id}.html\" class=\"external\">#{link_text}</a>"
|
292
|
+
end
|
293
|
+
end
|
294
|
+
result
|
295
|
+
end
|
296
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require_relative "doc_item"
|
2
|
-
|
3
|
-
class TodoBlock < DocItem
|
4
|
-
|
5
|
-
attr_accessor :text
|
6
|
-
|
7
|
-
def initialize(text)
|
8
|
-
@text = text
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_html
|
12
|
-
s = ''
|
13
|
-
f_text = format_string(@text)
|
14
|
-
if @@html_table_render_in_progress
|
15
|
-
s += "</table>\n"
|
16
|
-
@@html_table_render_in_progress = false
|
17
|
-
end
|
18
|
-
|
19
|
-
s += "<div class=\"todoblock\"><p>#{f_text}</div>\n"
|
20
|
-
return s
|
21
|
-
end
|
1
|
+
require_relative "doc_item"
|
2
|
+
|
3
|
+
class TodoBlock < DocItem
|
4
|
+
|
5
|
+
attr_accessor :text
|
6
|
+
|
7
|
+
def initialize(text)
|
8
|
+
@text = text
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_html
|
12
|
+
s = ''
|
13
|
+
f_text = format_string(@text)
|
14
|
+
if @@html_table_render_in_progress
|
15
|
+
s += "</table>\n"
|
16
|
+
@@html_table_render_in_progress = false
|
17
|
+
end
|
18
|
+
|
19
|
+
s += "<div class=\"todoblock\"><p>#{f_text}</div>\n"
|
20
|
+
return s
|
21
|
+
end
|
22
22
|
end
|