muwu 3.2.0 → 4.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/muwu/cli/help/summary +1 -1
  3. data/lib/muwu/cli/help/view +2 -2
  4. data/lib/muwu/controller/controller_interaction.rb +10 -4
  5. data/lib/muwu/default/default.rb +2 -8
  6. data/lib/muwu/helper/html_href_helper.rb +77 -77
  7. data/lib/muwu/helper/outline_helper.rb +22 -24
  8. data/lib/muwu/helper/regexp_lib.rb +26 -51
  9. data/lib/muwu/helper/sanitizer_helper.rb +5 -5
  10. data/lib/muwu/manifest/manifest.rb +52 -70
  11. data/lib/muwu/manifest_task/document_html.rb +16 -22
  12. data/lib/muwu/manifest_task/text.rb +13 -13
  13. data/lib/muwu/manifest_task/{text_item.rb → topic.rb} +9 -9
  14. data/lib/muwu/manifest_task_builder/text_builder.rb +24 -24
  15. data/lib/muwu/manifest_task_builder/{text_item_builder.rb → topic_builder.rb} +48 -74
  16. data/lib/muwu/project/project.rb +0 -8
  17. data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +57 -62
  18. data/lib/muwu/project_builder/assets/config/css/base/index.scss +3 -2
  19. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +35 -57
  20. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +2 -14
  21. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +6 -11
  22. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +35 -57
  23. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +2 -48
  24. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +18 -23
  25. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_topic.scss +38 -0
  26. data/lib/muwu/project_builder/assets/config/css/colors/dark.scss +33 -31
  27. data/lib/muwu/project_builder/assets/config/css/colors/index.scss +2 -1
  28. data/lib/muwu/project_builder/assets/config/css/colors/light.scss +33 -33
  29. data/lib/muwu/project_builder/project_validator.rb +7 -7
  30. data/lib/muwu/project_exception/{lynx_not_available.rb → no_html_viewer_configured.rb} +2 -2
  31. data/lib/muwu/project_exception/{text_source_file_not_found.rb → topic_source_file_not_found.rb} +6 -7
  32. data/lib/muwu/project_options/project_options.rb +4 -1
  33. data/lib/muwu/project_options_builder/project_option_validator_key.rb +17 -19
  34. data/lib/muwu/project_options_builder/project_option_validator_value.rb +42 -59
  35. data/lib/muwu/render_concat/render_concat.rb +22 -22
  36. data/lib/muwu/render_html_partial/js_library/navigation.js +1 -1
  37. data/lib/muwu/render_html_partial/render_contents.rb +139 -139
  38. data/lib/muwu/render_html_partial/render_document_html.rb +2 -2
  39. data/lib/muwu/render_html_partial/render_metadata.rb +25 -37
  40. data/lib/muwu/render_html_partial/render_navigator.rb +39 -39
  41. data/lib/muwu/render_html_partial/render_subcontents.rb +142 -143
  42. data/lib/muwu/render_html_partial/render_text.rb +11 -11
  43. data/lib/muwu/render_html_partial/render_title.rb +21 -21
  44. data/lib/muwu/render_html_partial/{render_text_item.rb → render_topic.rb} +62 -35
  45. data/lib/muwu/render_html_partial_builder/render_contents_builder.rb +17 -23
  46. data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +3 -9
  47. data/lib/muwu/render_html_partial_builder/render_text_builder.rb +11 -11
  48. data/lib/muwu/render_html_partial_builder/render_topic_builder.rb +281 -0
  49. data/lib/muwu/render_inspector/render_inspector.rb +58 -58
  50. data/lib/muwu/viewer/viewer.rb +2 -2
  51. data/lib/muwu.rb +2 -7
  52. metadata +30 -78
  53. data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +0 -24
  54. data/lib/muwu/render_html/render_markup_to_html.rb +0 -87
  55. data/lib/muwu/render_html_partial_builder/render_text_item_builder.rb +0 -274
  56. data/lib/muwu/var/deflistdiv.rb +0 -239
@@ -1,239 +0,0 @@
1
- # Process definition lists
2
- #
3
- # Based on Javascript version: https://github.com/markdown-it/markdown-it-deflist
4
- #------------------------------------------------------------------------------
5
-
6
- ### MUWU <div></div> wrapper
7
- ### a <div> element will wrap each <dt><dd> pair for semantic separation and greater layout control
8
- ### description item <div> within <dl> is consistent with WHATWG spec for HTML5
9
-
10
-
11
- include MarkdownIt::Common::Utils
12
-
13
- module Muwu
14
- module Var
15
- module MotionMarkdownItPlugins
16
- class Deflistdiv
17
-
18
- #------------------------------------------------------------------------------
19
- def self.init_plugin(md)
20
- md.block.ruler.before('paragraph', 'deflist',
21
- lambda { |state, startLine, endLine, silent| Deflistdiv.deflist(state, startLine, endLine, silent) },
22
- {alt: ['', 'paragraph', 'reference']})
23
- end
24
-
25
- # Search `[:~][\n ]`, returns next pos after marker on success
26
- # or -1 on fail.
27
- #------------------------------------------------------------------------------
28
- def self.skipMarker(state, line)
29
- start = state.bMarks[line] + state.tShift[line]
30
- max = state.eMarks[line]
31
-
32
- return -1 if (start >= max)
33
-
34
- # Check bullet
35
- marker = charCodeAt(state.src, start)
36
- start += 1
37
- return -1 if (marker != 0x7E && marker != 0x3A) # '~' ':'
38
-
39
- pos = state.skipSpaces(start)
40
-
41
- # require space after ":"
42
- return -1 if (start == pos)
43
-
44
- # no empty definitions, e.g. " : "
45
- return -1 if (pos >= max)
46
-
47
- return start
48
- end
49
-
50
- #------------------------------------------------------------------------------
51
- def self.markTightParagraphs(state, idx)
52
- level = state.level + 2
53
- i = idx + 2
54
- l = state.tokens.length - 2
55
- while i < l
56
- if (state.tokens[i].level == level && state.tokens[i].type == 'paragraph_open')
57
- state.tokens[i + 2].hidden = true
58
- state.tokens[i].hidden = true
59
- i += 2
60
- end
61
- i += 1
62
- end
63
- end
64
-
65
- #------------------------------------------------------------------------------
66
- def self.deflist(state, startLine, endLine, silent)
67
- if silent
68
- # quirk: validation mode validates a dd block only, not a whole deflist
69
- return false if (state.ddIndent < 0)
70
- return skipMarker(state, startLine) >= 0
71
- end
72
-
73
- nextLine = startLine + 1
74
- return false if nextLine >= endLine
75
-
76
- if state.isEmpty(nextLine)
77
- nextLine += 1
78
- return false if nextLine >= endLine
79
- end
80
-
81
- return false if (state.sCount[nextLine] < state.blkIndent)
82
- contentStart = skipMarker(state, nextLine)
83
- return false if (contentStart < 0)
84
-
85
- # Start list
86
- listTokIdx = state.tokens.length
87
- tight = true
88
-
89
- token = state.push('dl_open', 'dl', 1)
90
- token.map = listLines = [ startLine, 0 ]
91
-
92
- #
93
- # Iterate list items
94
- #
95
-
96
- dtLine = startLine
97
- ddLine = nextLine
98
-
99
- # One definition list can contain multiple DTs,
100
- # and one DT can be followed by multiple DDs.
101
- #
102
- # Thus, there is two loops here, and label is
103
- # needed to break out of the second one
104
- # OUTER:
105
- while true
106
- break_outer = false
107
- prevEmptyEnd = false
108
-
109
- ### MUWU <div></div> wrapper
110
- ### open with <div>
111
- token = state.push('div_open', 'div', 1)
112
-
113
- token = state.push('dt_open', 'dt', 1)
114
- token.map = [ dtLine, dtLine ]
115
-
116
- token = state.push('inline', '', 0)
117
- token.map = [ dtLine, dtLine ]
118
- token.content = state.getLines(dtLine, dtLine + 1, state.blkIndent, false).strip
119
- token.children = []
120
-
121
- token = state.push('dt_close', 'dt', -1)
122
-
123
- while true
124
- token = state.push('dd_open', 'dd', 1)
125
- token.map = itemLines = [ nextLine, 0 ]
126
-
127
- pos = contentStart
128
- max = state.eMarks[ddLine]
129
- offset = state.sCount[ddLine] + contentStart - (state.bMarks[ddLine] + state.tShift[ddLine])
130
-
131
- while pos < max
132
- ch = charCodeAt(state.src, pos)
133
-
134
- if isSpace(ch)
135
- if ch == 0x09
136
- offset += 4 - offset % 4
137
- else
138
- offset += 1
139
- end
140
- else
141
- break
142
- end
143
-
144
- pos += 1
145
- end
146
-
147
- contentStart = pos
148
-
149
- oldTight = state.tight
150
- oldDDIndent = state.ddIndent
151
- oldIndent = state.blkIndent
152
- oldTShift = state.tShift[ddLine]
153
- oldSCount = state.sCount[ddLine]
154
- oldParentType = state.parentType
155
- state.blkIndent = state.ddIndent = state.sCount[ddLine] + 2
156
- state.tShift[ddLine] = contentStart - state.bMarks[ddLine]
157
- state.sCount[ddLine] = offset
158
- state.tight = true
159
- state.parentType = 'deflist'
160
-
161
- state.md.block.tokenize(state, ddLine, endLine, true)
162
-
163
- # If any of list item is tight, mark list as tight
164
- if (!state.tight || prevEmptyEnd)
165
- tight = false
166
- end
167
- # Item become loose if finish with empty line,
168
- # but we should filter last element, because it means list finish
169
- prevEmptyEnd = (state.line - ddLine) > 1 && state.isEmpty(state.line - 1)
170
-
171
- state.tShift[ddLine] = oldTShift
172
- state.sCount[ddLine] = oldSCount
173
- state.tight = oldTight
174
- state.parentType = oldParentType
175
- state.blkIndent = oldIndent
176
- state.ddIndent = oldDDIndent
177
-
178
- token = state.push('dd_close', 'dd', -1)
179
-
180
- itemLines[1] = nextLine = state.line
181
-
182
- break_outer = true and break if (nextLine >= endLine)
183
- break_outer = true and break if (state.sCount[nextLine] < state.blkIndent)
184
- contentStart = skipMarker(state, nextLine)
185
- break if (contentStart < 0)
186
-
187
- ddLine = nextLine
188
-
189
- # go to the next loop iteration:
190
- # insert DD tag and repeat checking
191
- end
192
- break if break_outer
193
-
194
- break if (nextLine >= endLine)
195
- dtLine = nextLine
196
-
197
- break if (state.isEmpty(dtLine))
198
- break if (state.sCount[dtLine] < state.blkIndent)
199
-
200
- ddLine = dtLine + 1
201
- break if (ddLine >= endLine)
202
- ddLine += 1 if (state.isEmpty(ddLine))
203
- break if (ddLine >= endLine)
204
-
205
- break if (state.sCount[ddLine] < state.blkIndent)
206
- contentStart = skipMarker(state, ddLine)
207
- break if (contentStart < 0)
208
-
209
- # go to the next loop iteration:
210
- # insert DT and DD tags and repeat checking
211
-
212
- ### MUWU <div></div> wrapper
213
- ### close with </div>
214
- token = state.push('div_close', 'div', -1)
215
-
216
- end
217
-
218
- ### MUWU <div></div> wrapper
219
- ### close with </div>
220
- ### the previous while loop does not push a div_close with the last item
221
- token = state.push('div_close', 'div', -1)
222
-
223
- # Finalize list
224
- token = state.push('dl_close', 'dl', -1)
225
- listLines[1] = nextLine
226
- state.line = nextLine
227
-
228
- # mark paragraphs tight if needed
229
- if (tight)
230
- markTightParagraphs(state, listTokIdx)
231
- end
232
-
233
- return true
234
- end
235
-
236
- end
237
- end
238
- end
239
- end