Almirah 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- 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 +97 -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 +379 -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,61 +1,97 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'doc_item'
|
4
|
-
|
5
|
-
class MarkdownTable < DocItem
|
6
|
-
attr_accessor :column_names, :rows, :heading_row, :is_separator_detected
|
7
|
-
|
8
|
-
def initialize(doc, heading_row)
|
9
|
-
super(doc)
|
10
|
-
@heading_row = heading_row
|
11
|
-
|
12
|
-
res = /^[|](.*[|])/.match(heading_row)
|
13
|
-
@column_names = if res
|
14
|
-
res[1].split('|')
|
15
|
-
else
|
16
|
-
['# ERROR# ']
|
17
|
-
end
|
18
|
-
@rows = []
|
19
|
-
@is_separator_detected = false
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'doc_item'
|
4
|
+
|
5
|
+
class MarkdownTable < DocItem
|
6
|
+
attr_accessor :column_names, :rows, :heading_row, :is_separator_detected, :column_aligns
|
7
|
+
|
8
|
+
def initialize(doc, heading_row)
|
9
|
+
super(doc)
|
10
|
+
@heading_row = heading_row
|
11
|
+
|
12
|
+
res = /^[|](.*[|])/.match(heading_row)
|
13
|
+
@column_names = if res
|
14
|
+
res[1].split('|')
|
15
|
+
else
|
16
|
+
['# ERROR# ']
|
17
|
+
end
|
18
|
+
@rows = []
|
19
|
+
@is_separator_detected = false
|
20
|
+
@column_aligns = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_separator(line)
|
24
|
+
res = /^[|](.*[|])/.match(line)
|
25
|
+
columns = if res
|
26
|
+
res[1].split('|')
|
27
|
+
else
|
28
|
+
['# ERROR# ']
|
29
|
+
end
|
30
|
+
|
31
|
+
columns.each do |c|
|
32
|
+
res = /(:?)(-{3,})(:?)/.match(c)
|
33
|
+
@column_aligns << if res.length == 4
|
34
|
+
if (res[1] != '') && (res[2] != '') && (res[3] != '')
|
35
|
+
'center'
|
36
|
+
elsif (res[1] != '') && (res[2] != '') && (res[3] == '')
|
37
|
+
'left'
|
38
|
+
elsif (res[1] == '') && (res[2] != '') && (res[3] != '')
|
39
|
+
'right'
|
40
|
+
else
|
41
|
+
'default'
|
42
|
+
end
|
43
|
+
else
|
44
|
+
'default'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_row(row)
|
50
|
+
columns = row.split('|')
|
51
|
+
@rows.append(columns.map!(&:strip))
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_html
|
56
|
+
s = ''
|
57
|
+
if @@html_table_render_in_progress
|
58
|
+
s += "</table>\n"
|
59
|
+
@@html_table_render_in_progress = false
|
60
|
+
end
|
61
|
+
|
62
|
+
s += "<table class=\"markdown_table\">\n"
|
63
|
+
s += "\t<thead>"
|
64
|
+
|
65
|
+
@column_names.each do |h|
|
66
|
+
s += " <th>#{h}</th>"
|
67
|
+
end
|
68
|
+
|
69
|
+
s += " </thead>\n"
|
70
|
+
|
71
|
+
@rows.each do |row|
|
72
|
+
s += "\t<tr>\n"
|
73
|
+
row.each_with_index do |col, index|
|
74
|
+
if col.to_i.positive? && col.to_i.to_s == col # autoalign cells with numbers
|
75
|
+
s += "\t\t<td style=\"text-align: center;\">#{col}</td>\n"
|
76
|
+
else
|
77
|
+
align = ''
|
78
|
+
case @column_aligns[index]
|
79
|
+
when 'left'
|
80
|
+
align = 'style="text-align: left;"'
|
81
|
+
when 'right'
|
82
|
+
align = 'style="text-align: right;"'
|
83
|
+
when 'center'
|
84
|
+
align = 'style="text-align: center;"'
|
85
|
+
end
|
86
|
+
f_text = format_string(col)
|
87
|
+
s += "\t\t<td #{align}>#{f_text}</td>\n"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
s += "\t</tr>\n"
|
91
|
+
end
|
92
|
+
|
93
|
+
s += "</table>\n"
|
94
|
+
|
95
|
+
s
|
96
|
+
end
|
97
|
+
end
|
@@ -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
|