muwu 3.1.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/muwu/cli/help/concat +2 -4
  3. data/lib/muwu/cli/help/summary +1 -1
  4. data/lib/muwu/cli/help/view +2 -2
  5. data/lib/muwu/controller/controller.rb +1 -1
  6. data/lib/muwu/controller/controller_interaction.rb +10 -4
  7. data/lib/muwu/default/default.rb +2 -8
  8. data/lib/muwu/helper/html_href_helper.rb +77 -77
  9. data/lib/muwu/helper/outline_helper.rb +22 -24
  10. data/lib/muwu/helper/regexp_lib.rb +26 -51
  11. data/lib/muwu/helper/sanitizer_helper.rb +5 -5
  12. data/lib/muwu/manifest/manifest.rb +52 -70
  13. data/lib/muwu/manifest_task/document_html.rb +16 -22
  14. data/lib/muwu/manifest_task/text.rb +13 -13
  15. data/lib/muwu/manifest_task/{text_item.rb → topic.rb} +9 -9
  16. data/lib/muwu/manifest_task_builder/text_builder.rb +24 -24
  17. data/lib/muwu/manifest_task_builder/{text_item_builder.rb → topic_builder.rb} +48 -74
  18. data/lib/muwu/project/project.rb +0 -8
  19. data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +57 -62
  20. data/lib/muwu/project_builder/assets/config/css/base/index.scss +3 -2
  21. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +35 -57
  22. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +2 -14
  23. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +6 -11
  24. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +35 -57
  25. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +2 -48
  26. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +18 -23
  27. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_topic.scss +38 -0
  28. data/lib/muwu/project_builder/assets/config/css/colors/dark.scss +33 -31
  29. data/lib/muwu/project_builder/assets/config/css/colors/index.scss +2 -1
  30. data/lib/muwu/project_builder/assets/config/css/colors/light.scss +33 -33
  31. data/lib/muwu/project_builder/project_validator.rb +7 -7
  32. data/lib/muwu/project_exception/no_html_viewer_configured.rb +23 -0
  33. data/lib/muwu/project_exception/{text_source_file_not_found.rb → topic_source_file_not_found.rb} +6 -7
  34. data/lib/muwu/project_exception/{lynx_not_available.rb → viewer_missing_home_document.rb} +2 -2
  35. data/lib/muwu/project_options/project_options.rb +4 -1
  36. data/lib/muwu/project_options_builder/project_option_validator_key.rb +17 -19
  37. data/lib/muwu/project_options_builder/project_option_validator_value.rb +42 -59
  38. data/lib/muwu/render_concat/render_concat.rb +22 -22
  39. data/lib/muwu/render_html_partial/js_library/navigation.js +1 -1
  40. data/lib/muwu/render_html_partial/render_contents.rb +139 -139
  41. data/lib/muwu/render_html_partial/render_document_html.rb +2 -2
  42. data/lib/muwu/render_html_partial/render_metadata.rb +25 -37
  43. data/lib/muwu/render_html_partial/render_navigator.rb +39 -39
  44. data/lib/muwu/render_html_partial/render_subcontents.rb +142 -143
  45. data/lib/muwu/render_html_partial/render_text.rb +11 -11
  46. data/lib/muwu/render_html_partial/render_title.rb +21 -21
  47. data/lib/muwu/render_html_partial/{render_text_item.rb → render_topic.rb} +62 -35
  48. data/lib/muwu/render_html_partial_builder/render_contents_builder.rb +17 -23
  49. data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +3 -9
  50. data/lib/muwu/render_html_partial_builder/render_text_builder.rb +11 -11
  51. data/lib/muwu/render_html_partial_builder/render_topic_builder.rb +281 -0
  52. data/lib/muwu/render_inspector/render_inspector.rb +58 -58
  53. data/lib/muwu/viewer/viewer.rb +18 -11
  54. data/lib/muwu.rb +2 -7
  55. metadata +31 -78
  56. data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +0 -24
  57. data/lib/muwu/render_html/render_markup_to_html.rb +0 -87
  58. data/lib/muwu/render_html_partial_builder/render_text_item_builder.rb +0 -274
  59. data/lib/muwu/var/deflistdiv.rb +0 -239
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb244270b9a3f8c14b33190cd8145d7e2492d7360185f7004df15ddce25b8a63
4
- data.tar.gz: 647c1138722fd6dc8a4bf9ad41776797b1dffed79e5dd2e39c21a0e109633831
3
+ metadata.gz: 5e6d222cd47218dfdadbdebbeec54a34e9a21d3fd712ea8d41167a3e4202fa76
4
+ data.tar.gz: 68fa281753870cecb29570f3f56897ebb8f764a6f793a4600a55c04b54d42144
5
5
  SHA512:
6
- metadata.gz: f0031172eff2715affff5e76f0dcf93159e08f443a8d8efb86d1d7c237be8c3dc49a18cac38f79c23cab4e2670f7a19d180ca4eeb20c15fca4cb08ff0449181d
7
- data.tar.gz: 790dcbeda168f13f47da07a868b9f71fabac2d1ecb2f015f8b6bbc94f128116be66bc0d613b418993a624858896fee2e49d7d0c0f086b0a22f560e2527bd3fcd
6
+ metadata.gz: 610febd5bb1e383bf2c185b4861a0029d30566e2bd445bdac8ee0c381e4b073142f9c805d0275e439c7be6d9d6217270418d2dcc5765bdf1d6584dae03a61a50
7
+ data.tar.gz: d5bf793b752727bc8dc9d527645996fd32dadf42a74041852ea123f7b1df39b43dac2a4ca9553bf40cd704f9d8cffc2f39714e1678d91271a2953bda73631c4d
@@ -1,8 +1,6 @@
1
1
  - muwu concat
2
2
  - Combine all source files from the outline into a single markdown
3
3
  document.
4
-
5
- * Compiling a project will overwrite any previous output files without
6
- any warning.
7
4
 
8
- * This feature is still experimental.
5
+ * Compiling a project will overwrite any previous output files without
6
+ any warning.
@@ -10,7 +10,7 @@ Command line:
10
10
  muwu reset compiled reset the `compiled/` subdirectory
11
11
  muwu reset css reset the default CSS files
12
12
  muwu sync synchronize from/to a remote location (requires rsync)
13
- muwu view view a compiled project (requires lynx)
13
+ muwu view view a compiled project (shortcut for `open compiled/[index.html]`)
14
14
 
15
15
  For more detailed instructions:
16
16
  muwu help [command]
@@ -1,3 +1,3 @@
1
1
  - muwu view
2
- - View a compiled project in `compiled/` using lynx. Lynx must be installed
3
- on the local system.
2
+ - Shortcut for `open compiled/[index.html]`.
3
+ - Assumes a default web browser will open the file.
@@ -149,7 +149,7 @@ module Muwu
149
149
  if @project.does_not_have_crucial_files
150
150
  reply_folder_does_not_have_valid_project
151
151
  else
152
- Viewer.new(@project)
152
+ Viewer.new(@project).view
153
153
  end
154
154
  end
155
155
 
@@ -96,8 +96,10 @@ module Muwu
96
96
  def render_reset_compiled_heading
97
97
  puts '# Muwu'
98
98
  puts '# Reset `compiled/`'
99
+ puts
99
100
  puts '- This will remove all contents of the `compiled/` folder.'
100
101
  puts '- This action cannot be undone.'
102
+ puts
101
103
  end
102
104
 
103
105
 
@@ -109,13 +111,17 @@ module Muwu
109
111
  def render_reset_css_heading(project)
110
112
  puts '# Muwu'
111
113
  puts '# Reset CSS'
112
- puts '- This will reset the following files and folders to their original state:'
114
+ puts ''
115
+ puts 'This will reset the following files and folders to their original state:'
113
116
  determine_reset_css_files(project).each do |file|
114
- puts " * #{file}"
117
+ puts " - #{file}"
115
118
  end
116
- puts "- If #{project.path_css_extensions} does not exist, it will be created."
117
- puts ' Otherwise, its existing contents will remain unchanged.'
119
+ puts
120
+ puts "If #{project.path_css_extensions} does not exist, it will be created."
121
+ puts 'Otherwise, its existing contents will remain unchanged.'
122
+ puts
118
123
  puts '- This action cannot be undone'
124
+ puts
119
125
  end
120
126
 
121
127
 
@@ -1,7 +1,6 @@
1
1
  module Muwu
2
2
  module Default
3
3
 
4
-
5
4
  FILENAMES = {
6
5
  css_manifest: 'index.scss',
7
6
  metadata: 'metadata.yml',
@@ -9,7 +8,6 @@ module Muwu
9
8
  outline: 'outline.yml'
10
9
  }
11
10
 
12
-
13
11
  FILEPATHS = {
14
12
  compiled: './compiled',
15
13
  css: './config/css',
@@ -19,16 +17,14 @@ module Muwu
19
17
  text: './text'
20
18
  }
21
19
 
22
-
23
20
  PROJECT_OPTIONS = {
24
- contents_section_numbers_receive_link: true,
25
21
  generate_navigators_automatically: true,
26
22
  generate_subcontents_automatically: false,
23
+ generate_topic_inner_identifiers: false,
27
24
  html_head_includes_metadata_tags: true,
28
25
  html_lang: nil,
29
26
  html_uses_javascript_navigation: false,
30
- markdown_allows_raw_html: true,
31
- markdown_renderer: 'commonmarker',
27
+ markdown_allows_raw_html: false,
32
28
  outline_text_pathnames: 'flexible',
33
29
  output_destination: 'file',
34
30
  output_file_css_basename: nil,
@@ -46,11 +42,9 @@ module Muwu
46
42
  warning_if_parent_heading_lacks_source: true
47
43
  }
48
44
 
49
-
50
45
  PROJECT_OUTLINE = {
51
46
  default_text_block_name: 'main'
52
47
  }
53
48
 
54
-
55
49
  end
56
50
  end
@@ -1,101 +1,101 @@
1
1
  module Muwu
2
2
  module Helper
3
- class HtmlHrefHelper
4
-
5
-
6
- include Muwu
7
-
8
-
9
- attr_accessor(
10
- :origin_task,
11
- )
12
-
13
-
14
- def initialize(origin_task)
15
- @origin_task = origin_task
16
- @project = origin_task.project
3
+ module HrefHelper
4
+
5
+
6
+ module_function
7
+
8
+
9
+ def id_contents_item(topic)
10
+ hyphenate(['contents', topic.text_root_name, topic.id])
17
11
  end
18
-
19
-
20
-
21
- public
22
-
23
-
24
- def to_text_item(text_object)
25
- result = ''
26
- case @origin_task
27
- when ManifestTask::Contents
28
- result = target_text_filename(text_object) + attr_id(:text, text_object)
29
- when ManifestTask::Subcontents
30
- result = attr_id(:text, text_object)
31
- end
32
- result
12
+
13
+
14
+ def id_subcontents_item(topic)
15
+ hyphenate(['subcontents', topic.text_root_name, topic.id])
33
16
  end
34
-
35
-
36
- def to_contents_heading(text_object)
37
- result = ''
38
- case @origin_task
39
- when ManifestTask::TextItem
40
- filename = target_contents_filename(text_object)
41
- anchor_id = attr_id(:contents, text_object)
42
- result = filename + anchor_id
43
- end
44
- result
17
+
18
+
19
+ def id_topic_header(topic)
20
+ hyphenate(['text', topic.text_root_name, topic.id])
21
+ end
22
+
23
+
24
+ def link_to_contents_item(topic, from: nil)
25
+ target_filename_contents(topic, from: from) + '#' + id_contents_item(topic)
26
+ end
27
+
28
+
29
+ def link_to_project_home(project)
30
+ project.manifest.find_document_html_by_index(0).destination.output_filename
45
31
  end
46
32
 
47
33
 
48
- def to_document_top
34
+ def link_to_document_top
49
35
  '#top'
50
36
  end
51
37
 
52
38
 
53
- def to_project_home
54
- @project.manifest.find_document_html_by_index(0).destination.output_filename
39
+ def link_to_subcontents_item(topic, from: nil)
40
+ target_filename_subcontents(topic, from: from) + '#' + id_subcontents_item(topic)
41
+ end
42
+
43
+
44
+ def link_to_topic_header(topic, from: nil)
45
+ target_filename_topic(topic, from: from) + '#' + id_topic_header(topic)
55
46
  end
56
-
57
47
 
58
48
 
59
49
  private
60
-
61
-
62
- def attr_id(target, text_object)
63
- prefix = '#'
64
- block_type = target.to_s
65
- root_name = target_text_root_name(text_object)
66
- section_number = target_section_number_as_attr(text_object)
67
- prefix + ([block_type, root_name, section_number].compact.join('_'))
50
+
51
+
52
+ def self.hyphenate(a)
53
+ a.join('-')
68
54
  end
69
-
70
-
71
- def target_contents_filename(text_object)
72
- result = ''
73
- if @project.has_multiple_html_documents
74
- result = File.basename(@project.manifest.contents_block_by_name(text_object.text_root_name).destination.output_filename)
55
+
56
+
57
+ def self.target_filename_contents(topic, from: nil)
58
+ contents_destination_output_filename = topic.project.manifest.contents_block_filename_for(topic.text_root_name)
59
+ case from
60
+ when :topic
61
+ if contents_destination_output_filename == topic.destination.output_filename
62
+ return ''
63
+ else
64
+ return contents_destination_output_filename
65
+ end
66
+ else
67
+ return contents_destination_output_filename
75
68
  end
76
- result
77
69
  end
78
-
79
-
80
- def target_text_filename(text_object)
81
- result = ''
82
- if @project.has_multiple_html_documents
83
- result = File.basename(text_object.destination.output_filename)
70
+
71
+
72
+ def self.target_filename_subcontents(topic, from: nil)
73
+ case from
74
+ when :topic
75
+ return ''
76
+ else
77
+ return topic.destination.output_filename
84
78
  end
85
- result
86
- end
87
-
88
-
89
- def target_text_root_name(text_object)
90
- text_object.text_root_name
91
79
  end
92
-
93
-
94
- def target_section_number_as_attr(text_object)
95
- text_object.numbering_to_depth_max.join('_')
80
+
81
+
82
+ def self.target_filename_topic(topic, from: nil)
83
+ case from
84
+ when :contents
85
+ contents_destination_output_filename = topic.project.manifest.contents_block_filename_for(topic.text_root_name)
86
+ if contents_destination_output_filename == topic.destination.output_filename
87
+ return ''
88
+ else
89
+ return topic.destination.output_filename
90
+ end
91
+ when :subcontents
92
+ return ''
93
+ else
94
+ return topic.destination.output_filename
95
+ end
96
96
  end
97
-
98
-
97
+
98
+
99
99
  end
100
100
  end
101
101
  end
@@ -1,25 +1,25 @@
1
1
  module Muwu
2
2
  module Helper
3
3
  class OutlineHelper
4
-
5
-
4
+
5
+
6
6
  include Muwu::Helper
7
-
8
-
7
+
8
+
9
9
  def initialize(outline_fragment)
10
10
  @outline_fragment = outline_fragment
11
11
  end
12
-
13
-
12
+
13
+
14
14
 
15
15
  public
16
-
17
-
16
+
17
+
18
18
  def includes_navigator
19
19
  indicates_navigator || includes_navigator_in_array
20
20
  end
21
-
22
-
21
+
22
+
23
23
  def includes_navigator_in_array
24
24
  (is_array) && (@outline_fragment.select{ |step| OutlineHelper.type_of(step) == :navigator }.any?)
25
25
  end
@@ -43,8 +43,8 @@ module Muwu
43
43
  def indicates_metadata
44
44
  indicates_metadata_hash || indicates_metadata_string
45
45
  end
46
-
47
-
46
+
47
+
48
48
  def indicates_metadata_hash
49
49
  (is_hash) && (RegexpLib.outline_metadata =~ @outline_fragment.flatten[0])
50
50
  end
@@ -58,8 +58,8 @@ module Muwu
58
58
  def indicates_navigator
59
59
  (is_string) && (RegexpLib.outline_navigator =~ @outline_fragment)
60
60
  end
61
-
62
-
61
+
62
+
63
63
  def indicates_outline_fragment
64
64
  is_array
65
65
  end
@@ -93,13 +93,13 @@ module Muwu
93
93
  def indicates_title_hash
94
94
  (is_hash) && (RegexpLib.outline_title =~ @outline_fragment.flatten[0])
95
95
  end
96
-
97
-
96
+
97
+
98
98
  def indicates_title_string
99
99
  (is_string) && (RegexpLib.outline_title =~ @outline_fragment)
100
100
  end
101
-
102
-
101
+
102
+
103
103
  def is_array
104
104
  Array === @outline_fragment
105
105
  end
@@ -123,8 +123,6 @@ module Muwu
123
123
  def text_step_flexible_suggests_file
124
124
  if @outline_fragment.to_s =~ RegexpLib.file_ext_md
125
125
  true
126
- elsif @outline_fragment.to_s =~ RegexpLib.file_ext_haml
127
- true
128
126
  else
129
127
  false
130
128
  end
@@ -133,8 +131,8 @@ module Muwu
133
131
 
134
132
 
135
133
  protected
136
-
137
-
134
+
135
+
138
136
  def self.type_of(step)
139
137
  s = new(step)
140
138
  if s.indicates_contents
@@ -153,8 +151,8 @@ module Muwu
153
151
  :title
154
152
  end
155
153
  end
156
-
154
+
157
155
 
158
156
  end
159
157
  end
160
- end
158
+ end
@@ -1,76 +1,51 @@
1
1
  module Muwu
2
2
  module Helper
3
3
  module RegexpLib
4
-
5
-
4
+
5
+
6
6
  module_function
7
-
8
-
9
- # def regexp_path_relative_current
10
- # /\A.\//
11
- # end
12
- #
13
- #
14
- # def regexp_path_segmenter_fw_slash
15
- # /[\/\\]/
16
- # end
17
-
18
-
19
- def file_ext_haml
20
- /.haml\z/i
21
- end
22
7
 
23
8
 
24
9
  def file_ext_md
25
10
  /.md\z/i
26
11
  end
27
-
28
-
29
- def haml_heading
30
- /\A%h\d*/i
31
- end
32
-
33
-
34
- def haml_heading_plus_whitespace
35
- /\A%h\d*\s*/i
36
- end
37
-
38
-
12
+
13
+
39
14
  def markdown_heading
40
15
  /\A#+/
41
16
  end
42
-
43
-
17
+
18
+
44
19
  def markdown_heading_plus_whitespace
45
20
  /\A#+\s*/
46
21
  end
47
-
48
-
49
- def metadata_key_date_of_this_edition
22
+
23
+
24
+ def metadata_key_date_of_this_edition
50
25
  /\Adate\s*of\s*this\s*edition/i
51
26
  end
52
-
53
-
27
+
28
+
54
29
  def not_alphanumeric_underscore_or_single_dot
55
30
  /[^a-zA-Z0-9_\.]/
56
31
  end
57
-
32
+
58
33
 
59
34
  def outline_metadata
60
35
  /\Ametadata/i
61
36
  end
62
-
63
-
37
+
38
+
64
39
  def outline_navigator
65
40
  /\Anavigator/i
66
41
  end
67
-
68
-
42
+
43
+
69
44
  def outline_contents
70
45
  /\Acontents/i
71
46
  end
72
-
73
-
47
+
48
+
74
49
  def outline_subcontents
75
50
  /\Asubcontents/i
76
51
  end
@@ -79,23 +54,23 @@ module Muwu
79
54
  def outline_text
80
55
  /\Atext/i
81
56
  end
82
-
83
-
57
+
58
+
84
59
  def outline_text_plus_whitespace
85
60
  /\Atext\s+/i
86
61
  end
87
-
88
-
62
+
63
+
89
64
  def outline_title
90
65
  /\Atitle/i
91
66
  end
92
-
93
-
67
+
68
+
94
69
  def path_two_or_more_dots
95
70
  /\.{2,}/
96
71
  end
97
-
98
-
72
+
73
+
99
74
  end
100
75
  end
101
76
  end
@@ -14,22 +14,22 @@ module Muwu
14
14
  end
15
15
 
16
16
 
17
- def sanitize_text_item_basename(basename)
17
+ def sanitize_topic_basename(basename)
18
18
  basename.to_s.gsub(RegexpLib.path_two_or_more_dots,'_')
19
19
  end
20
20
 
21
21
 
22
- def sanitize_text_item_path(path)
22
+ def sanitize_topic_path(path)
23
23
  case path
24
24
  when Array
25
- return path.map { |p| sanitize_text_item_path_segment(p) }
25
+ return path.map { |p| sanitize_topic_path_segment(p) }
26
26
  when Integer, String
27
- return sanitize_text_item_path_segment(path)
27
+ return sanitize_topic_path_segment(path)
28
28
  end
29
29
  end
30
30
 
31
31
 
32
- def sanitize_text_item_path_segment(path)
32
+ def sanitize_topic_path_segment(path)
33
33
  path.to_s.downcase.gsub(/\s/,'_').gsub(/\W/,'').gsub(/_{2,}/,'_')
34
34
  end
35
35