muwu 3.2.0 → 5.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} +32 -11
  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 +9 -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 +134 -148
  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 +137 -152
  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 +15 -27
  46. data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +3 -15
  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
@@ -2,15 +2,15 @@ module Muwu
2
2
  module RenderHtmlPartial
3
3
  class Title
4
4
 
5
-
5
+
6
6
  include Muwu
7
-
8
-
7
+
8
+
9
9
  attr_accessor(
10
10
  :destination,
11
11
  :metadata
12
12
  )
13
-
13
+
14
14
 
15
15
  def render
16
16
  @destination.margin_to_zero
@@ -21,17 +21,17 @@ module Muwu
21
21
  end
22
22
  @destination.margin_to_zero
23
23
  end
24
-
25
-
24
+
25
+
26
26
  def render_title_metadata
27
- @destination.margin_indent do
27
+ @destination.margin_indent do
28
28
  @metadata.each_pair do |key, value|
29
29
  write_tag_h1(key, value)
30
30
  end
31
31
  end
32
32
  end
33
-
34
-
33
+
34
+
35
35
  def write_tag_div_close
36
36
  @destination.write_line tag_div_close
37
37
  end
@@ -40,32 +40,32 @@ module Muwu
40
40
  def write_tag_div_open
41
41
  @destination.write_line tag_div_open
42
42
  end
43
-
43
+
44
44
 
45
45
  def write_tag_h1(key, value)
46
46
  @destination.write_line tag_h1(key, value)
47
47
  end
48
-
49
-
48
+
49
+
50
50
 
51
51
  private
52
-
52
+
53
53
 
54
54
  def tag_h1(key, value)
55
- "<h1 data-metadata_key='#{key.downcase}'>#{value}</h1>"
55
+ "<h1 data-title-attr='#{key.downcase}'>#{value}</h1>"
56
56
  end
57
-
58
-
57
+
58
+
59
59
  def tag_div_close
60
60
  "</div>"
61
61
  end
62
-
63
-
62
+
63
+
64
64
  def tag_div_open
65
- "<div class='title'>"
66
- end
65
+ "<div data-document-block='title'>"
66
+ end
67
+
67
68
 
68
-
69
69
  end
70
70
  end
71
71
  end
@@ -1,33 +1,35 @@
1
1
  module Muwu
2
2
  module RenderHtmlPartial
3
- class TextItem
3
+ class Topic
4
4
 
5
5
 
6
6
  include Muwu
7
7
 
8
-
9
8
  require 'commonmarker'
9
+ require 'nokogiri'
10
10
 
11
11
 
12
12
  attr_accessor(
13
+ :commonmarker_options,
14
+ :depth,
13
15
  :destination,
14
16
  :distinct,
15
17
  :does_have_source_text,
16
18
  :end_links,
19
+ :generate_inner_identifiers,
17
20
  :heading,
18
21
  :heading_origin,
19
- :html_attr_id,
22
+ :html_id,
23
+ :id,
20
24
  :is_parent_heading,
21
- :markup_renderer,
22
25
  :numbering,
26
+ :numbering_as_text,
23
27
  :project,
24
- :section_depth,
25
- :section_number_as_attr,
26
- :section_number_as_text,
27
- :sections,
28
28
  :source_filename_absolute,
29
29
  :source_filename_relative,
30
- :subsections_are_distinct,
30
+ :source_relative_segments,
31
+ :subtopics,
32
+ :subtopics_are_distinct,
31
33
  :text_root_name,
32
34
  :will_render_section_number
33
35
  )
@@ -39,11 +41,11 @@ module Muwu
39
41
  render_section_number
40
42
  render_heading
41
43
  render_text
42
- if (@is_parent_heading == true) && (@subsections_are_distinct == true)
44
+ if (@is_parent_heading == true) && (@subtopics_are_distinct == true)
43
45
  render_end_links
44
- render_sections
45
- elsif (@is_parent_heading == true) && (@subsections_are_distinct == false)
46
- render_sections
46
+ render_subtopics
47
+ elsif (@is_parent_heading == true) && (@subtopics_are_distinct == false)
48
+ render_subtopics
47
49
  render_end_links
48
50
  elsif (@is_parent_heading == false)
49
51
  render_end_links
@@ -83,10 +85,10 @@ module Muwu
83
85
  end
84
86
 
85
87
 
86
- def render_sections
88
+ def render_subtopics
87
89
  @destination.padding_vertical(1) do
88
- @sections.each do |section|
89
- section.render
90
+ @subtopics.each do |subtopic|
91
+ subtopic.render
90
92
  end
91
93
  end
92
94
  end
@@ -140,11 +142,10 @@ module Muwu
140
142
 
141
143
 
142
144
  def write_text_source_to_html
143
- @destination.write_inline source_to_html
145
+ @destination.write_inline source_convert_to_html
144
146
  end
145
147
 
146
148
 
147
-
148
149
  private
149
150
 
150
151
 
@@ -160,13 +161,49 @@ module Muwu
160
161
  end
161
162
 
162
163
 
163
- def source_to_html
164
- @markup_renderer.render(@source_filename_absolute)
164
+ def source_convert_to_html
165
+ case File.extname(@source_filename_absolute).downcase
166
+ when '.md'
167
+ source_html_parse(source_html_from_md)
168
+ end
169
+ end
170
+
171
+
172
+ def source_html_from_md
173
+ Commonmarker.to_html(File.read(@source_filename_absolute), options: @commonmarker_options, plugins: { syntax_highligher: nil })
174
+ end
175
+
176
+
177
+ def source_html_parse(source_html)
178
+ fragment = Nokogiri::HTML5.fragment(source_html)
179
+ fragment.css('a.anchor[aria-hidden]').each { |node| node.remove }
180
+ starting_heading = nil
181
+ if fragment.children.any? && fragment.children.first.name =~ /\Ah\d{1}\z/i
182
+ starting_heading = fragment.first_element_child.remove
183
+ starting_heading['data-topic'] = 'section-heading'
184
+ starting_heading['data-depth'] = @depth
185
+ end
186
+ if @generate_inner_identifiers
187
+ %w(blockquote dd dl dt h1 h2 h3 h4 h5 h6 li ol p pre table td tr ul).each do |element|
188
+ fragment.css(element).each do |node|
189
+ data_source_class = []
190
+ @source_relative_segments.each_index do |i|
191
+ data_source_class << "#{source_relative_segments[i]}-#{node.name}"
192
+ end
193
+ node['data-topic-source-class'] = data_source_class.join(' ')
194
+ node['data-topic-id-class'] = "#{@id}-#{node.name}"
195
+ end
196
+ end
197
+ end
198
+ if starting_heading
199
+ fragment.children.first.previous = starting_heading
200
+ end
201
+ fragment.to_html
165
202
  end
166
203
 
167
204
 
168
205
  def tag_nav_a(name, href)
169
- "<a class='document_link' href='#{href}'>[#{name}]</a>"
206
+ "<a class='document_link' data-topic='navigation-link' href='#{href}'>[#{name}]</a>"
170
207
  end
171
208
 
172
209
 
@@ -181,7 +218,7 @@ module Muwu
181
218
 
182
219
 
183
220
  def tag_nav_end_links_open
184
- "<nav class='document_links'>"
221
+ "<nav data-topic='navigation'>"
185
222
  end
186
223
 
187
224
 
@@ -191,7 +228,7 @@ module Muwu
191
228
 
192
229
 
193
230
  def tag_heading
194
- "<h1>#{@heading}</h1>"
231
+ "<div data-topic='section-heading' data-depth='#{@depth}'>#{@heading}</div>"
195
232
  end
196
233
 
197
234
 
@@ -201,17 +238,7 @@ module Muwu
201
238
 
202
239
 
203
240
  def tag_section_open
204
- "<section data-section_depth='#{@section_depth}' data-section_number='#{@section_number_as_text}' data-source='#{@source_filename_relative}' id='#{@html_attr_id}'>"
205
- end
206
-
207
-
208
- def tag_section_with_source_open
209
- "<section data-section_depth='#{@section_depth}' data-section_number='#{@section_number_as_text}' data-source='#{@source_filename_relative}' id='#{@html_attr_id}'>"
210
- end
211
-
212
-
213
- def tag_section_without_source_open
214
- "<section data-section_depth='#{@section_depth}' data-section_number='#{@section_number_as_text}' id='#{@html_attr_id}'>"
241
+ "<section data-document-block='topic' data-topic-depth='#{@depth}' data-section-number='#{@numbering_as_text}' data-source='#{@source_filename_relative}' id='#{@html_id}'>"
215
242
  end
216
243
 
217
244
 
@@ -221,7 +248,7 @@ module Muwu
221
248
 
222
249
 
223
250
  def tag_span_section_number
224
- "<h1 class='section_number'>#{@section_number_as_text}</h1>"
251
+ "<div data-topic='section-number' data-depth='#{@depth}'>#{@numbering_as_text}</div>"
225
252
  end
226
253
 
227
254
 
@@ -7,9 +7,9 @@ module Muwu
7
7
 
8
8
 
9
9
  attr_accessor(
10
- :task_contents,
11
10
  :project,
12
11
  :renderer,
12
+ :task_contents,
13
13
  :text_root_name
14
14
  )
15
15
 
@@ -32,11 +32,9 @@ module Muwu
32
32
  @text_root_name = task_contents.text_root_name
33
33
  phase_1_set_text_root_name
34
34
  phase_2_set_destination
35
- phase_2_set_href_helper
36
35
  phase_2_set_html_attr_id
37
- phase_2_set_item_depth_max
38
36
  phase_2_set_project
39
- phase_2_set_sections
37
+ phase_2_set_topics
40
38
  phase_2_set_will_render_section_numbers
41
39
  end
42
40
 
@@ -51,28 +49,18 @@ module Muwu
51
49
  end
52
50
 
53
51
 
54
- def phase_2_set_href_helper
55
- @renderer.href_helper = Helper::HtmlHrefHelper.new(@task_contents)
56
- end
57
-
58
-
59
52
  def phase_2_set_html_attr_id
60
- @renderer.html_attr_id = ['contents', @text_root_name].join('_')
53
+ @renderer.html_attr_id = ['contents', @text_root_name].join('-')
61
54
  end
62
55
 
63
56
 
64
- def phase_2_set_item_depth_max
65
- @renderer.item_depth_max = @project.options.render_sections_distinctly_depth_max
66
- end
67
-
68
-
69
57
  def phase_2_set_project
70
58
  @renderer.project = @project
71
59
  end
72
-
73
-
74
- def phase_2_set_sections
75
- @renderer.sections = determine_sections
60
+
61
+
62
+ def phase_2_set_topics
63
+ @renderer.topics = determine_topics
76
64
  end
77
65
 
78
66
 
@@ -83,18 +71,18 @@ module Muwu
83
71
 
84
72
 
85
73
  private
86
-
87
-
88
- def determine_sections
89
- determine_text_root_blocks.map { |trb| trb.sections }.flatten
74
+
75
+
76
+ def determine_topics
77
+ determine_text_root_blocks.map { |trb| trb.topics }.flatten
90
78
  end
91
-
92
-
79
+
80
+
93
81
  def determine_text_root_blocks
94
82
  @task_contents.text_blocks_by_name(@text_root_name)
95
83
  end
96
-
97
-
84
+
85
+
98
86
  end
99
87
  end
100
88
  end
@@ -31,9 +31,7 @@ module Muwu
31
31
  @task_subcontents = task_subcontents
32
32
  @text_root_name = task_subcontents.text_root_name
33
33
  set_destination
34
- set_href_helper
35
34
  set_html_attr_id
36
- set_item_depth_max
37
35
  set_project
38
36
  set_text_root_blocks
39
37
  set_will_render_section_numbers
@@ -45,25 +43,15 @@ module Muwu
45
43
  end
46
44
 
47
45
 
48
- def set_href_helper
49
- @renderer.href_helper = Helper::HtmlHrefHelper.new(@task_subcontents)
50
- end
51
-
52
-
53
46
  def set_html_attr_id
54
- @renderer.html_attr_id = ['subcontents'].join('_')
55
- end
56
-
57
-
58
- def set_item_depth_max
59
- @renderer.item_depth_max = @project.options.render_sections_distinctly_depth_max
47
+ @renderer.html_attr_id = 'subcontents'
60
48
  end
61
49
 
62
50
 
63
51
  def set_project
64
52
  @renderer.project = @project
65
53
  end
66
-
54
+
67
55
 
68
56
  def set_text_root_blocks
69
57
  @renderer.text_root_blocks = @task_subcontents.text_root_blocks
@@ -73,7 +61,7 @@ module Muwu
73
61
  def set_text_root_name
74
62
  @renderer.text_root_name = @text_root_name
75
63
  end
76
-
64
+
77
65
 
78
66
  def set_will_render_section_numbers
79
67
  @renderer.will_render_section_numbers = @project.options.render_section_numbers
@@ -31,7 +31,7 @@ module Muwu
31
31
  set_destination
32
32
  set_project
33
33
  set_text_root_name
34
- set_sections
34
+ set_topics
35
35
  finally_set_html_attr_id
36
36
  end
37
37
 
@@ -56,8 +56,8 @@ module Muwu
56
56
  end
57
57
 
58
58
 
59
- def set_sections
60
- @renderer.sections = determine_sections
59
+ def set_topics
60
+ @renderer.topics = determine_topics
61
61
  end
62
62
 
63
63
 
@@ -65,18 +65,18 @@ module Muwu
65
65
  private
66
66
 
67
67
 
68
- def determine_sections
69
- sections = []
70
- @manifest_text.sections.each do |section|
71
- sections << build_text_item(section)
68
+ def determine_topics
69
+ topics = []
70
+ @manifest_text.topics.each do |topic|
71
+ topics << build_topic(topic)
72
72
  end
73
- sections
73
+ topics
74
74
  end
75
75
 
76
76
 
77
- def build_text_item(text_item)
78
- RenderHtmlPartialBuilder::TextItemBuilder.build do |b|
79
- b.build_from_manifest_text_item(text_item)
77
+ def build_topic(topic)
78
+ RenderHtmlPartialBuilder::TopicBuilder.build do |b|
79
+ b.build_from_manifest_topic(topic)
80
80
  end
81
81
  end
82
82