muwu 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/muwu +5 -0
- data/lib/muwu.rb +38 -0
- data/lib/muwu/cli/cli.rb +143 -0
- data/lib/muwu/cli/cli_help.rb +28 -0
- data/lib/muwu/cli/help/compile +22 -0
- data/lib/muwu/cli/help/concat +8 -0
- data/lib/muwu/cli/help/heading +2 -0
- data/lib/muwu/cli/help/inspect +7 -0
- data/lib/muwu/cli/help/new +8 -0
- data/lib/muwu/cli/help/reset +14 -0
- data/lib/muwu/cli/help/summary +14 -0
- data/lib/muwu/controller/controller.rb +120 -0
- data/lib/muwu/controller/controller_interaction.rb +146 -0
- data/lib/muwu/default/default.rb +51 -0
- data/lib/muwu/destination/destination.rb +212 -0
- data/lib/muwu/destination_builder/destination_builder.rb +127 -0
- data/lib/muwu/helper/hash_helper.rb +37 -0
- data/lib/muwu/helper/html_href_helper.rb +101 -0
- data/lib/muwu/helper/outline_helper.rb +160 -0
- data/lib/muwu/helper/regexp_lib.rb +101 -0
- data/lib/muwu/helper/sanitizer_helper.rb +50 -0
- data/lib/muwu/manifest/manifest.rb +158 -0
- data/lib/muwu/manifest_builder/manifest_builder.rb +102 -0
- data/lib/muwu/manifest_task/contents.rb +42 -0
- data/lib/muwu/manifest_task/document_css.rb +25 -0
- data/lib/muwu/manifest_task/document_html.rb +69 -0
- data/lib/muwu/manifest_task/document_js.rb +25 -0
- data/lib/muwu/manifest_task/metadata.rb +35 -0
- data/lib/muwu/manifest_task/navigator.rb +29 -0
- data/lib/muwu/manifest_task/subcontents.rb +48 -0
- data/lib/muwu/manifest_task/text.rb +51 -0
- data/lib/muwu/manifest_task/text_item.rb +124 -0
- data/lib/muwu/manifest_task/title.rb +34 -0
- data/lib/muwu/manifest_task_builder/contents_builder.rb +88 -0
- data/lib/muwu/manifest_task_builder/document_css_builder.rb +63 -0
- data/lib/muwu/manifest_task_builder/document_html_builder.rb +210 -0
- data/lib/muwu/manifest_task_builder/document_js_builder.rb +69 -0
- data/lib/muwu/manifest_task_builder/metadata_builder.rb +118 -0
- data/lib/muwu/manifest_task_builder/navigator_builder.rb +78 -0
- data/lib/muwu/manifest_task_builder/subcontents_builder.rb +90 -0
- data/lib/muwu/manifest_task_builder/text_builder.rb +125 -0
- data/lib/muwu/manifest_task_builder/text_item_builder.rb +314 -0
- data/lib/muwu/manifest_task_builder/title_builder.rb +122 -0
- data/lib/muwu/project/project.rb +430 -0
- data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +138 -0
- data/lib/muwu/project_builder/assets/config/css/base/index.scss +11 -0
- data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +23 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +58 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +17 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +13 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +58 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +48 -0
- data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +22 -0
- data/lib/muwu/project_builder/assets/config/css/colors/dark.scss +32 -0
- data/lib/muwu/project_builder/assets/config/css/colors/index.scss +1 -0
- data/lib/muwu/project_builder/assets/config/css/colors/light.scss +34 -0
- data/lib/muwu/project_builder/assets/config/css/extensions/index.scss +1 -0
- data/lib/muwu/project_builder/assets/config/css/index.scss +19 -0
- data/lib/muwu/project_builder/assets/config/css_debugger/debug_section_text.scss +27 -0
- data/lib/muwu/project_builder/project_reader.rb +144 -0
- data/lib/muwu/project_builder/project_reset_css.rb +95 -0
- data/lib/muwu/project_builder/project_starter.rb +27 -0
- data/lib/muwu/project_builder/project_validator.rb +157 -0
- data/lib/muwu/project_builder/project_writer.rb +127 -0
- data/lib/muwu/project_exception/css_manifest_file_not_found.rb +23 -0
- data/lib/muwu/project_exception/dry_output_recommended_with_multiple_documents.rb +19 -0
- data/lib/muwu/project_exception/metadata_file_not_found.rb +24 -0
- data/lib/muwu/project_exception/metadata_value_not_given.rb +42 -0
- data/lib/muwu/project_exception/multiple_documents_outlined_with_stdout.rb +18 -0
- data/lib/muwu/project_exception/multiple_formats_requested_with_stdout.rb +18 -0
- data/lib/muwu/project_exception/navigator_not_recommended_with_stdout.rb +23 -0
- data/lib/muwu/project_exception/navigators_will_be_generated_automatically.rb +23 -0
- data/lib/muwu/project_exception/option_key_not_understood.rb +23 -0
- data/lib/muwu/project_exception/option_not_validatable.rb +23 -0
- data/lib/muwu/project_exception/option_value_not_understood.rb +24 -0
- data/lib/muwu/project_exception/options_file_not_found.rb +24 -0
- data/lib/muwu/project_exception/outline_file_not_found.rb +24 -0
- data/lib/muwu/project_exception/outline_step_not_understood.rb +23 -0
- data/lib/muwu/project_exception/output_already_open.rb +18 -0
- data/lib/muwu/project_exception/output_not_open.rb +18 -0
- data/lib/muwu/project_exception/subcontents_will_be_generated_automatically copy.rb +23 -0
- data/lib/muwu/project_exception/target_project_folder_already_exists.rb +24 -0
- data/lib/muwu/project_exception/text_source_file_not_found.rb +26 -0
- data/lib/muwu/project_exception_handler/fatal.rb +39 -0
- data/lib/muwu/project_options/project_options.rb +54 -0
- data/lib/muwu/project_options_builder/project_option_validator.rb +37 -0
- data/lib/muwu/project_options_builder/project_option_validator_key.rb +56 -0
- data/lib/muwu/project_options_builder/project_option_validator_value.rb +300 -0
- data/lib/muwu/project_options_builder/project_options_reader.rb +80 -0
- data/lib/muwu/render_concat/render_concat.rb +80 -0
- data/lib/muwu/render_html/render_html.rb +101 -0
- data/lib/muwu/render_html/render_markup_to_html.rb +87 -0
- data/lib/muwu/render_html_builder/render_css_builder.rb +34 -0
- data/lib/muwu/render_html_builder/render_html_builder.rb +34 -0
- data/lib/muwu/render_html_builder/render_js_builder.rb +34 -0
- data/lib/muwu/render_html_partial/js_library/_init_bare.js +7 -0
- data/lib/muwu/render_html_partial/js_library/_zepto.min.js +2 -0
- data/lib/muwu/render_html_partial/js_library/init.js +10 -0
- data/lib/muwu/render_html_partial/js_library/navigation.js +140 -0
- data/lib/muwu/render_html_partial/render_contents.rb +369 -0
- data/lib/muwu/render_html_partial/render_document_css.rb +45 -0
- data/lib/muwu/render_html_partial/render_document_html.rb +397 -0
- data/lib/muwu/render_html_partial/render_document_js.rb +37 -0
- data/lib/muwu/render_html_partial/render_js_library.rb +54 -0
- data/lib/muwu/render_html_partial/render_metadata.rb +120 -0
- data/lib/muwu/render_html_partial/render_navigator.rb +136 -0
- data/lib/muwu/render_html_partial/render_subcontents.rb +374 -0
- data/lib/muwu/render_html_partial/render_text.rb +74 -0
- data/lib/muwu/render_html_partial/render_text_item.rb +230 -0
- data/lib/muwu/render_html_partial/render_title.rb +71 -0
- data/lib/muwu/render_html_partial_builder/render_contents_builder.rb +100 -0
- data/lib/muwu/render_html_partial_builder/render_document_css_builder.rb +46 -0
- data/lib/muwu/render_html_partial_builder/render_document_html_builder.rb +211 -0
- data/lib/muwu/render_html_partial_builder/render_document_js_builder.rb +52 -0
- data/lib/muwu/render_html_partial_builder/render_metadata_builder.rb +47 -0
- data/lib/muwu/render_html_partial_builder/render_navigator_builder.rb +74 -0
- data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +85 -0
- data/lib/muwu/render_html_partial_builder/render_text_builder.rb +86 -0
- data/lib/muwu/render_html_partial_builder/render_text_item_builder.rb +274 -0
- data/lib/muwu/render_html_partial_builder/render_title_builder.rb +47 -0
- data/lib/muwu/render_inspector/render_inspector.rb +224 -0
- data/lib/muwu/var/deflistdiv.rb +239 -0
- data/lib/muwu_loader.rb +35 -0
- data/test/what_no_tests.md +5 -0
- metadata +251 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
module Muwu
|
2
|
+
module Default
|
3
|
+
|
4
|
+
|
5
|
+
FILENAMES = {
|
6
|
+
css_manifest: 'index.scss',
|
7
|
+
metadata: 'metadata.yml',
|
8
|
+
options: 'options.yml',
|
9
|
+
outline: 'outline.yml'
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
FILEPATHS = {
|
14
|
+
css: './config/css',
|
15
|
+
metadata: '',
|
16
|
+
options: '',
|
17
|
+
outline: '',
|
18
|
+
text: './text'
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
PROJECT_OPTIONS = {
|
23
|
+
generate_navigators_automatically: true,
|
24
|
+
generate_subcontents_automatically: false,
|
25
|
+
html_head_includes_metadata_tags: true,
|
26
|
+
html_lang: nil,
|
27
|
+
html_uses_javascript_navigation: false,
|
28
|
+
markdown_allows_raw_html: true,
|
29
|
+
markdown_renderer: 'commonmarker',
|
30
|
+
outline_text_pathnames: 'flexible',
|
31
|
+
output_destination: 'file',
|
32
|
+
output_file_css_basename: nil,
|
33
|
+
output_file_html_basename: 'index',
|
34
|
+
output_file_js_basename: nil,
|
35
|
+
output_formats: ['html','css','js'],
|
36
|
+
render_punctuation_smart: true,
|
37
|
+
render_section_end_links: ['contents', 'top'],
|
38
|
+
render_section_numbers: true,
|
39
|
+
render_sections_distinctly_depth_max: nil,
|
40
|
+
render_title_section_metadata: ['title', 'subtitle', 'author'],
|
41
|
+
warning_if_parent_heading_lacks_source: true
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
PROJECT_OUTLINE = {
|
46
|
+
default_text_block_name: 'main'
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
module Muwu
|
2
|
+
class Destination
|
3
|
+
|
4
|
+
|
5
|
+
include Muwu
|
6
|
+
|
7
|
+
|
8
|
+
attr_accessor(
|
9
|
+
:margin_current,
|
10
|
+
:output_class,
|
11
|
+
:output_filename,
|
12
|
+
:output_working_directory
|
13
|
+
)
|
14
|
+
attr_writer(
|
15
|
+
:output
|
16
|
+
)
|
17
|
+
|
18
|
+
|
19
|
+
MARGIN = ' '
|
20
|
+
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@margin_depth = 0
|
24
|
+
@output = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def inspect
|
29
|
+
["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def inspect_instance_variables
|
34
|
+
self.instance_variables.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }.join(", ")
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
public
|
40
|
+
|
41
|
+
|
42
|
+
def margin_dec
|
43
|
+
@margin_depth = @margin_depth.to_i - 1
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def margin_inc
|
48
|
+
@margin_depth = @margin_depth.to_i + 1
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def margin_indent
|
53
|
+
margin_inc
|
54
|
+
yield
|
55
|
+
margin_dec
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def margin_to_zero
|
60
|
+
@margin_depth = 0
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def output
|
65
|
+
begin
|
66
|
+
if output_is_closed
|
67
|
+
raise ProjectExceptionHandler::Fatal.new(ProjectException::OutputNotOpen.new)
|
68
|
+
elsif output_is_opened
|
69
|
+
@output
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def output_is_closed
|
76
|
+
@output == nil
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def output_is_opened
|
81
|
+
@output != nil
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def output_stream
|
86
|
+
announce_open
|
87
|
+
output_open
|
88
|
+
yield
|
89
|
+
output_close
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def padding_vertical(n)
|
94
|
+
output.print ("\n" * n)
|
95
|
+
yield
|
96
|
+
output.print ("\n" * n)
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def write_inline(value)
|
101
|
+
write_value(value)
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def write_inline_end(value)
|
106
|
+
write_value(value)
|
107
|
+
write_lf
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def write_inline_indented(value)
|
112
|
+
write_margin
|
113
|
+
write_value(value)
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
def write_lf
|
118
|
+
output.print "\n"
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
def write_line(value)
|
123
|
+
write_margin
|
124
|
+
write_value(value)
|
125
|
+
write_lf
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def write_margin
|
130
|
+
output.print render_current_margin
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
def write_value(value)
|
135
|
+
output.print value
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
|
143
|
+
def announce_open
|
144
|
+
if @output_class == 'file'
|
145
|
+
puts "- Writing `#{output_filename}`."
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def destination_file_open
|
151
|
+
filename = File.join(@output_working_directory, @output_filename)
|
152
|
+
File.new(filename, 'w')
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
def destination_stdout
|
157
|
+
$stdout
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def output_close
|
162
|
+
begin
|
163
|
+
if output_is_closed
|
164
|
+
raise ProjectExceptionHandler::Fatal.new(ProjectException::OutputNotOpen.new)
|
165
|
+
elsif output_is_opened
|
166
|
+
output_close_assignment
|
167
|
+
end
|
168
|
+
end
|
169
|
+
margin_to_zero
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
def output_close_assignment
|
174
|
+
if File === @output
|
175
|
+
@output.close
|
176
|
+
@output = nil
|
177
|
+
else
|
178
|
+
@output = nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
def output_open
|
184
|
+
margin_to_zero
|
185
|
+
begin
|
186
|
+
if output_is_opened
|
187
|
+
raise ProjectExceptionHandler::Fatal.new(ProjectException::OutputAlreadyOpen.new)
|
188
|
+
elsif output_is_closed
|
189
|
+
output_open_assignment
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
def output_open_assignment
|
196
|
+
case @output_class
|
197
|
+
when 'file'
|
198
|
+
@output = destination_file_open
|
199
|
+
when 'stdout'
|
200
|
+
@output = destination_stdout
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
def render_current_margin
|
206
|
+
(MARGIN * @margin_depth.to_i)
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Muwu
|
2
|
+
class DestinationBuilder
|
3
|
+
|
4
|
+
|
5
|
+
include Muwu
|
6
|
+
|
7
|
+
|
8
|
+
attr_accessor(
|
9
|
+
:destination,
|
10
|
+
:project
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
def self.build
|
15
|
+
builder = new
|
16
|
+
yield(builder)
|
17
|
+
builder.destination
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@destination = Destination.new
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def build_css(project)
|
27
|
+
depends_on_project(project)
|
28
|
+
set_output_class
|
29
|
+
set_output_filename_css
|
30
|
+
set_output_working_directory
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def build_html(project, index)
|
35
|
+
depends_on_project(project)
|
36
|
+
set_output_class
|
37
|
+
set_output_filename_html(index)
|
38
|
+
set_output_working_directory
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def build_js(project)
|
43
|
+
depends_on_project(project)
|
44
|
+
set_output_class
|
45
|
+
set_output_filename_js
|
46
|
+
set_output_working_directory
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def depends_on_project(project)
|
51
|
+
@project = project
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def set_output_class
|
56
|
+
@destination.output_class = @project.output_destination
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def set_output_filename_css
|
61
|
+
if @destination.output_class == 'file'
|
62
|
+
@destination.output_filename = determine_output_filename_css
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def set_output_filename_html(index)
|
68
|
+
if @destination.output_class == 'file'
|
69
|
+
@destination.output_filename = determine_output_filename_html(index)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def set_output_filename_js
|
75
|
+
if @destination.output_class == 'file'
|
76
|
+
@destination.output_filename = determine_output_filename_js
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def set_output_working_directory
|
82
|
+
if @destination.output_class == 'file'
|
83
|
+
@destination.output_working_directory = @project.working_directory
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
|
92
|
+
def determine_output_filename_css
|
93
|
+
filename = ''
|
94
|
+
filename.concat @project.css_basename
|
95
|
+
filename.concat ".css"
|
96
|
+
filename
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def determine_output_filename_html(index)
|
101
|
+
filename = ''
|
102
|
+
filename.concat @project.html_basename
|
103
|
+
if index_is_integer_greater_than_zero(index)
|
104
|
+
filename.concat "_#{index}"
|
105
|
+
end
|
106
|
+
filename.concat ".html"
|
107
|
+
filename
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def determine_output_filename_js
|
112
|
+
filename = ''
|
113
|
+
filename.concat @project.js_basename
|
114
|
+
filename.concat ".js"
|
115
|
+
filename
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def index_is_integer_greater_than_zero(index)
|
120
|
+
(Integer === index) && (index >= 1)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Muwu
|
2
|
+
module Helper
|
3
|
+
module HashHelper
|
4
|
+
|
5
|
+
|
6
|
+
module_function
|
7
|
+
|
8
|
+
|
9
|
+
def human_readable_hash(incoming_hash)
|
10
|
+
result_hash = {}
|
11
|
+
incoming_hash.each_pair do |k, v|
|
12
|
+
key = human_readable_key(k)
|
13
|
+
value = human_readable_value(v)
|
14
|
+
result_hash[key] = value
|
15
|
+
end
|
16
|
+
result_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def human_readable_key(k)
|
21
|
+
k.to_s.gsub(/\A:/,'')
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def human_readable_value(v)
|
26
|
+
case v
|
27
|
+
when Array
|
28
|
+
return v.join(', ')
|
29
|
+
else
|
30
|
+
return v
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Muwu
|
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
|
17
|
+
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
|
33
|
+
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
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def to_document_top
|
49
|
+
'#top'
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def to_project_home
|
54
|
+
@project.manifest.find_document_html_by_index(0).destination.output_filename
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
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('_'))
|
68
|
+
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)
|
75
|
+
end
|
76
|
+
result
|
77
|
+
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)
|
84
|
+
end
|
85
|
+
result
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def target_text_root_name(text_object)
|
90
|
+
text_object.text_root_name
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def target_section_number_as_attr(text_object)
|
95
|
+
text_object.numbering_to_depth_max.join('_')
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|