coridoc-html 1.1.23
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/coridoc/html/asset_resolver.rb +174 -0
- data/lib/coridoc/html/builder.rb +94 -0
- data/lib/coridoc/html/cleaner.rb +236 -0
- data/lib/coridoc/html/config.rb +154 -0
- data/lib/coridoc/html/converter_base.rb +174 -0
- data/lib/coridoc/html/converters/a.rb +77 -0
- data/lib/coridoc/html/converters/aside.rb +20 -0
- data/lib/coridoc/html/converters/audio.rb +19 -0
- data/lib/coridoc/html/converters/base.rb +100 -0
- data/lib/coridoc/html/converters/blockquote.rb +25 -0
- data/lib/coridoc/html/converters/br.rb +17 -0
- data/lib/coridoc/html/converters/bypass.rb +82 -0
- data/lib/coridoc/html/converters/code.rb +25 -0
- data/lib/coridoc/html/converters/div.rb +23 -0
- data/lib/coridoc/html/converters/dl.rb +82 -0
- data/lib/coridoc/html/converters/drop.rb +26 -0
- data/lib/coridoc/html/converters/em.rb +23 -0
- data/lib/coridoc/html/converters/figure.rb +33 -0
- data/lib/coridoc/html/converters/h.rb +58 -0
- data/lib/coridoc/html/converters/head.rb +29 -0
- data/lib/coridoc/html/converters/hr.rb +17 -0
- data/lib/coridoc/html/converters/img.rb +105 -0
- data/lib/coridoc/html/converters/li.rb +39 -0
- data/lib/coridoc/html/converters/mark.rb +21 -0
- data/lib/coridoc/html/converters/markup.rb +93 -0
- data/lib/coridoc/html/converters/math.rb +42 -0
- data/lib/coridoc/html/converters/media_base.rb +48 -0
- data/lib/coridoc/html/converters/ol.rb +42 -0
- data/lib/coridoc/html/converters/p.rb +64 -0
- data/lib/coridoc/html/converters/pass_through.rb +15 -0
- data/lib/coridoc/html/converters/positional_formatting.rb +35 -0
- data/lib/coridoc/html/converters/pre.rb +60 -0
- data/lib/coridoc/html/converters/q.rb +25 -0
- data/lib/coridoc/html/converters/strong.rb +22 -0
- data/lib/coridoc/html/converters/sub.rb +20 -0
- data/lib/coridoc/html/converters/sup.rb +20 -0
- data/lib/coridoc/html/converters/table.rb +64 -0
- data/lib/coridoc/html/converters/td.rb +42 -0
- data/lib/coridoc/html/converters/text.rb +66 -0
- data/lib/coridoc/html/converters/tr.rb +27 -0
- data/lib/coridoc/html/converters/video.rb +27 -0
- data/lib/coridoc/html/converters.rb +104 -0
- data/lib/coridoc/html/drop/annotation_drop.rb +31 -0
- data/lib/coridoc/html/drop/base.rb +72 -0
- data/lib/coridoc/html/drop/bibliography_drop.rb +15 -0
- data/lib/coridoc/html/drop/bibliography_entry_drop.rb +24 -0
- data/lib/coridoc/html/drop/block_drop.rb +78 -0
- data/lib/coridoc/html/drop/definition_item_drop.rb +61 -0
- data/lib/coridoc/html/drop/definition_list_drop.rb +15 -0
- data/lib/coridoc/html/drop/document_drop.rb +52 -0
- data/lib/coridoc/html/drop/drop_factory.rb +64 -0
- data/lib/coridoc/html/drop/footnote_drop.rb +24 -0
- data/lib/coridoc/html/drop/image_drop.rb +35 -0
- data/lib/coridoc/html/drop/inline_element_drop.rb +43 -0
- data/lib/coridoc/html/drop/list_block_drop.rb +19 -0
- data/lib/coridoc/html/drop/list_item_drop.rb +20 -0
- data/lib/coridoc/html/drop/raw_inline_element_drop.rb +30 -0
- data/lib/coridoc/html/drop/table_cell_drop.rb +35 -0
- data/lib/coridoc/html/drop/table_drop.rb +15 -0
- data/lib/coridoc/html/drop/table_row_drop.rb +23 -0
- data/lib/coridoc/html/drop/term_drop.rb +24 -0
- data/lib/coridoc/html/drop/text_content_drop.rb +15 -0
- data/lib/coridoc/html/drop/toc_drop.rb +15 -0
- data/lib/coridoc/html/drop/toc_entry_drop.rb +32 -0
- data/lib/coridoc/html/drop.rb +40 -0
- data/lib/coridoc/html/errors.rb +11 -0
- data/lib/coridoc/html/escape.rb +29 -0
- data/lib/coridoc/html/frontmatter_meta.rb +157 -0
- data/lib/coridoc/html/html_converter.rb +161 -0
- data/lib/coridoc/html/input_config.rb +71 -0
- data/lib/coridoc/html/layout_renderer.rb +195 -0
- data/lib/coridoc/html/lint/registrations.rb +40 -0
- data/lib/coridoc/html/lint.rb +16 -0
- data/lib/coridoc/html/plugin.rb +93 -0
- data/lib/coridoc/html/plugins/plateau.rb +212 -0
- data/lib/coridoc/html/postprocessor.rb +19 -0
- data/lib/coridoc/html/reference_materializers/link.rb +44 -0
- data/lib/coridoc/html/reference_materializers/navigation.rb +77 -0
- data/lib/coridoc/html/reference_materializers.rb +22 -0
- data/lib/coridoc/html/render_options.rb +40 -0
- data/lib/coridoc/html/renderer.rb +136 -0
- data/lib/coridoc/html/section_numberable.rb +9 -0
- data/lib/coridoc/html/spa.rb +49 -0
- data/lib/coridoc/html/static.rb +57 -0
- data/lib/coridoc/html/tag_mapping.rb +106 -0
- data/lib/coridoc/html/template_caching.rb +31 -0
- data/lib/coridoc/html/template_config.rb +92 -0
- data/lib/coridoc/html/template_helpers.rb +66 -0
- data/lib/coridoc/html/template_locator.rb +120 -0
- data/lib/coridoc/html/theme.rb +7 -0
- data/lib/coridoc/html/title_text.rb +57 -0
- data/lib/coridoc/html/toc_builder.rb +114 -0
- data/lib/coridoc/html/toc_serializer.rb +32 -0
- data/lib/coridoc/html/transform/from_core_model.rb +35 -0
- data/lib/coridoc/html/transform/to_core_model.rb +39 -0
- data/lib/coridoc/html/version.rb +7 -0
- data/lib/coridoc/html.rb +246 -0
- metadata +255 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class BlockDrop < Base
|
|
7
|
+
def semantic_type
|
|
8
|
+
resolved_semantic_type.to_s
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def html_tag
|
|
12
|
+
TagMapping.tag_for(resolved_semantic_type)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def language
|
|
16
|
+
@model.language || @model.metadata('language')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def css_class
|
|
20
|
+
cls = TagMapping.css_class_for(resolved_semantic_type)
|
|
21
|
+
cls ? "block-#{semantic_type} #{cls}" : "block-#{semantic_type}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def content
|
|
25
|
+
content_to_liquid(@model.renderable_content)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def text
|
|
29
|
+
if verbatim?
|
|
30
|
+
Escape.escape_html(stripped_text)
|
|
31
|
+
elsif resolved_semantic_type == :pass
|
|
32
|
+
@model.flat_text.to_s
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def callouts
|
|
37
|
+
return [] unless verbatim?
|
|
38
|
+
|
|
39
|
+
@callouts ||= CoreModel::CalloutText.ordered(@model.callouts).map do |callout|
|
|
40
|
+
{ 'index' => callout.index, 'content' => Escape.escape_html(callout.content.to_s) }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def callouts?
|
|
45
|
+
!callouts.empty?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def hidden?
|
|
49
|
+
%i[comment reviewer].include?(resolved_semantic_type)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def raw?
|
|
53
|
+
resolved_semantic_type == :pass
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def hr?
|
|
57
|
+
resolved_semantic_type == :horizontal_rule
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def resolved_semantic_type
|
|
63
|
+
@resolved_semantic_type ||= @model.resolve_semantic_type || :paragraph
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def verbatim?
|
|
67
|
+
%i[source_code literal listing].include?(resolved_semantic_type)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def stripped_text
|
|
71
|
+
CoreModel::CalloutText.strip_markers(@model.flat_text.to_s, @model.callouts)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
DropFactory.register(CoreModel::Block, BlockDrop)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class DefinitionItemDrop < Base
|
|
7
|
+
def term
|
|
8
|
+
Escape.escape_html(stripped_term)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# All terms on this `<dt>`, escaped and id-stripped. Multi-term
|
|
12
|
+
# `<dt>`'s (AsciiDoc `term1::\nterm2::`) carry multiple entries;
|
|
13
|
+
# templates iterate this collection to emit one `<dt>` per term.
|
|
14
|
+
# Falls back to `[term]` for legacy callers that only set the
|
|
15
|
+
# singular `term` accessor.
|
|
16
|
+
def terms
|
|
17
|
+
raw = @model.terms
|
|
18
|
+
collection = raw.nil? || raw.empty? ? [@model.term.to_s] : raw.map(&:to_s)
|
|
19
|
+
collection.map { |t| Escape.escape_html(strip_term_id(t)) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def term_id
|
|
23
|
+
match = term_text.match(/\A\[\[([^\]]+)\]\]/)
|
|
24
|
+
match&.[](1)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def definitions
|
|
28
|
+
return [] unless @model.definitions
|
|
29
|
+
|
|
30
|
+
@model.definitions.map { |d| content_to_liquid(d) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def nested
|
|
34
|
+
nested_model = @model.nested
|
|
35
|
+
return nil unless nested_model.is_a?(CoreModel::DefinitionList) &&
|
|
36
|
+
nested_model.items&.any?
|
|
37
|
+
|
|
38
|
+
DropFactory.create(nested_model)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def term_text
|
|
44
|
+
@term_text ||= @model.term.to_s
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def stripped_term
|
|
48
|
+
term_text.sub(/\A\[\[[^\]]+\]\]/, '')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Strip a leading `[[id]]` anchor from a term string. Shared by
|
|
52
|
+
# `terms` (per-entry) and `stripped_term` (primary term).
|
|
53
|
+
def strip_term_id(text)
|
|
54
|
+
text.to_s.sub(/\A\[\[[^\]]+\]\]/, '')
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
DropFactory.register(CoreModel::DefinitionItem, DefinitionItemDrop)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class DefinitionListDrop < Base
|
|
7
|
+
def items
|
|
8
|
+
children_to_liquid(@model.items)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
DropFactory.register(CoreModel::DefinitionList, DefinitionListDrop)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class DocumentDrop < Base
|
|
7
|
+
include SectionNumberable
|
|
8
|
+
|
|
9
|
+
def template_type
|
|
10
|
+
return 'document' if @model.is_a?(CoreModel::DocumentElement)
|
|
11
|
+
|
|
12
|
+
'section'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def title
|
|
16
|
+
text = TitleText.resolve(@model.title)
|
|
17
|
+
return nil unless text && !text.empty?
|
|
18
|
+
|
|
19
|
+
if @section_number
|
|
20
|
+
Escape.escape_html("#{@section_number}. #{text}")
|
|
21
|
+
else
|
|
22
|
+
Escape.escape_html(text)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def children
|
|
27
|
+
children_to_liquid(@model.children)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def structural_type
|
|
31
|
+
case @model
|
|
32
|
+
when CoreModel::DocumentElement then 'document'
|
|
33
|
+
when CoreModel::SectionElement then 'section'
|
|
34
|
+
when CoreModel::HeaderElement then 'header'
|
|
35
|
+
when CoreModel::PreambleElement then 'preamble'
|
|
36
|
+
else 'structural'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def heading_level
|
|
41
|
+
if @model.is_a?(CoreModel::SectionElement)
|
|
42
|
+
[@model.heading_level + 1, 6].min
|
|
43
|
+
else
|
|
44
|
+
1
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
DropFactory.register(CoreModel::StructuralElement, DocumentDrop)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
module DropFactory
|
|
7
|
+
@registry = []
|
|
8
|
+
|
|
9
|
+
def self.register(model_class, drop_class)
|
|
10
|
+
@registry << [model_class, drop_class]
|
|
11
|
+
sort_registry!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.create(obj)
|
|
15
|
+
return nil if obj.nil?
|
|
16
|
+
return obj.map { |o| create(o) } if obj.is_a?(Array)
|
|
17
|
+
return Escape.escape_html(obj) if obj.is_a?(String)
|
|
18
|
+
return obj.to_s if obj.is_a?(Numeric) || obj.is_a?(TrueClass) || obj.is_a?(FalseClass)
|
|
19
|
+
|
|
20
|
+
pair = lookup_pair(obj)
|
|
21
|
+
return pair.last.new(obj) if pair
|
|
22
|
+
|
|
23
|
+
Escape.escape_html(obj.to_s)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.drop_class_for(model)
|
|
27
|
+
pair = lookup_pair(model)
|
|
28
|
+
pair&.last
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.template_type_for(model)
|
|
32
|
+
drop = drop_class_for(model)
|
|
33
|
+
drop&.new(model)&.template_type
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Walk the Drop namespace and trigger each declared autoload so the
|
|
37
|
+
# drop class body evaluates and self-registers. Called eagerly from
|
|
38
|
+
# drop.rb after autoloads are declared.
|
|
39
|
+
EAGER_LOAD_ORDER = %i[Base DropFactory AnnotationDrop BlockDrop ListBlockDrop ListItemDrop
|
|
40
|
+
TableDrop TableRowDrop TableCellDrop ImageDrop InlineElementDrop RawInlineElementDrop
|
|
41
|
+
BibliographyEntryDrop BibliographyDrop TocEntryDrop TocDrop DefinitionItemDrop
|
|
42
|
+
DefinitionListDrop TermDrop FootnoteDrop TextContentDrop DocumentDrop].freeze
|
|
43
|
+
private_constant :EAGER_LOAD_ORDER
|
|
44
|
+
|
|
45
|
+
def self.eager_load!
|
|
46
|
+
EAGER_LOAD_ORDER.each { |sym| Drop.const_get(sym) }
|
|
47
|
+
true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class << self
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def lookup_pair(obj)
|
|
54
|
+
@registry.find { |klass, _drop_class| obj.is_a?(klass) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def sort_registry!
|
|
58
|
+
@registry.sort_by! { |klass, _| -klass.ancestors.length }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class FootnoteDrop < Base
|
|
7
|
+
def footnote_id
|
|
8
|
+
@model.id || ''
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def content
|
|
12
|
+
Escape.escape_html(extract_text(@model.content || @model.inline_content))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def inline?
|
|
16
|
+
footnote_id.empty?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
DropFactory.register(CoreModel::FootnoteReference, FootnoteDrop)
|
|
21
|
+
DropFactory.register(CoreModel::Footnote, FootnoteDrop)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class ImageDrop < Base
|
|
7
|
+
def inline?
|
|
8
|
+
@model.inline == true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def src
|
|
12
|
+
@model.src
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def alt
|
|
16
|
+
@model.alt
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def width
|
|
20
|
+
@model.width
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def height
|
|
24
|
+
@model.height
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def caption
|
|
28
|
+
optional_text(@model.caption)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
DropFactory.register(CoreModel::Image, ImageDrop)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class InlineElementDrop < Base
|
|
7
|
+
def format_type
|
|
8
|
+
@model.resolve_format_type
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def html_tag
|
|
12
|
+
TagMapping.tag_for(format_type)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def href
|
|
16
|
+
case format_type
|
|
17
|
+
when 'link'
|
|
18
|
+
@model.target || @model.metadata('href') || '#'
|
|
19
|
+
when 'xref'
|
|
20
|
+
target = @model.target || @model.metadata('href') || ''
|
|
21
|
+
"##{target}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def text
|
|
26
|
+
Escape.escape_html(extract_text(@model.content))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def css_class
|
|
30
|
+
return @model.metadata('class') if format_type == 'span'
|
|
31
|
+
|
|
32
|
+
TagMapping.css_class_for(format_type)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def term_ref
|
|
36
|
+
@model.content.to_s if format_type == 'term'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
DropFactory.register(CoreModel::InlineElement, InlineElementDrop)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class ListBlockDrop < Base
|
|
7
|
+
def html_tag
|
|
8
|
+
TagMapping.tag_for(@model.marker_type)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def items
|
|
12
|
+
children_to_liquid(@model.items)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
DropFactory.register(CoreModel::ListBlock, ListBlockDrop)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class ListItemDrop < Base
|
|
7
|
+
def content
|
|
8
|
+
content_to_liquid(@model.content)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def nested_list
|
|
12
|
+
child = @model.nested_list
|
|
13
|
+
DropFactory.create(child) if child
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
DropFactory.register(CoreModel::ListItem, ListItemDrop)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
# Drop for CoreModel::RawInlineElement.
|
|
7
|
+
#
|
|
8
|
+
# Passthrough content is raw output-format markup (typically HTML)
|
|
9
|
+
# that the source author explicitly marked as "emit verbatim." The
|
|
10
|
+
# generic InlineElementDrop escapes content; this subclass skips
|
|
11
|
+
# escaping so the rendered output mirrors the author's intent.
|
|
12
|
+
#
|
|
13
|
+
# The Liquid template is shared with InlineElementDrop — only the
|
|
14
|
+
# data preparation differs. InlineElementDrop is autoloaded by the
|
|
15
|
+
# Drop namespace shell (drop.rb) and is guaranteed to load before
|
|
16
|
+
# this class via DropFactory.eager_load! ordering.
|
|
17
|
+
class RawInlineElementDrop < InlineElementDrop
|
|
18
|
+
def text
|
|
19
|
+
extract_text(@model.content).to_s
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def template_type
|
|
23
|
+
'inline_element'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
DropFactory.register(CoreModel::RawInlineElement, RawInlineElementDrop)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class TableCellDrop < Base
|
|
7
|
+
def header?
|
|
8
|
+
@model.header == true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def html_tag
|
|
12
|
+
TagMapping.tag_for(header? ? :table_header : :table_cell)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def colspan
|
|
16
|
+
@model.colspan&.to_s
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def rowspan
|
|
20
|
+
@model.rowspan&.to_s
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def style
|
|
24
|
+
"text-align: #{@model.alignment}" if @model.alignment
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def content
|
|
28
|
+
content_to_liquid(@model.renderable_content)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
DropFactory.register(CoreModel::TableCell, TableCellDrop)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class TableRowDrop < Base
|
|
7
|
+
def header?
|
|
8
|
+
@model.header == true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def html_tag
|
|
12
|
+
'tr'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def cells
|
|
16
|
+
children_to_liquid(@model.cells)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
DropFactory.register(CoreModel::TableRow, TableRowDrop)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class TermDrop < Base
|
|
7
|
+
def text
|
|
8
|
+
Escape.escape_html(@model.text.to_s)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def term_ref
|
|
12
|
+
@model.text.to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def css_class
|
|
16
|
+
t = @model.type || 'term'
|
|
17
|
+
"term term-#{t}"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
DropFactory.register(CoreModel::Term, TermDrop)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class TextContentDrop < Base
|
|
7
|
+
def text
|
|
8
|
+
Escape.escape_html(@model.text.to_s)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
DropFactory.register(CoreModel::TextContent, TextContentDrop)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Coridoc
|
|
4
|
+
module Html
|
|
5
|
+
module Drop
|
|
6
|
+
class TocEntryDrop < Base
|
|
7
|
+
def title
|
|
8
|
+
TitleText.escape(@model.title)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def number
|
|
12
|
+
@model.number
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def level
|
|
16
|
+
@model.level
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def children
|
|
20
|
+
children_to_liquid(@model.children)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def numbered_title
|
|
24
|
+
n = number
|
|
25
|
+
n ? "#{n}. #{title}" : title
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
DropFactory.register(CoreModel::TocEntry, TocEntryDrop)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Drop namespace — Liquid drop layer for template rendering.
|
|
4
|
+
#
|
|
5
|
+
# Each drop class is autoloaded from its own file (one class per file,
|
|
6
|
+
# mirroring the mirror/ReverseBuilder pattern). Eager loading is delegated
|
|
7
|
+
# to DropFactory.eager_load!, which triggers each autoload in dependency
|
|
8
|
+
# order so drops self-register with DropFactory at load time.
|
|
9
|
+
module Coridoc
|
|
10
|
+
module Html
|
|
11
|
+
module Drop
|
|
12
|
+
autoload :Base, "#{__dir__}/drop/base"
|
|
13
|
+
autoload :DropFactory, "#{__dir__}/drop/drop_factory"
|
|
14
|
+
autoload :AnnotationDrop, "#{__dir__}/drop/annotation_drop"
|
|
15
|
+
autoload :BlockDrop, "#{__dir__}/drop/block_drop"
|
|
16
|
+
autoload :ListBlockDrop, "#{__dir__}/drop/list_block_drop"
|
|
17
|
+
autoload :ListItemDrop, "#{__dir__}/drop/list_item_drop"
|
|
18
|
+
autoload :TableDrop, "#{__dir__}/drop/table_drop"
|
|
19
|
+
autoload :TableRowDrop, "#{__dir__}/drop/table_row_drop"
|
|
20
|
+
autoload :TableCellDrop, "#{__dir__}/drop/table_cell_drop"
|
|
21
|
+
autoload :ImageDrop, "#{__dir__}/drop/image_drop"
|
|
22
|
+
# InlineElementDrop must load before RawInlineElementDrop (subclass).
|
|
23
|
+
autoload :InlineElementDrop, "#{__dir__}/drop/inline_element_drop"
|
|
24
|
+
autoload :RawInlineElementDrop, "#{__dir__}/drop/raw_inline_element_drop"
|
|
25
|
+
autoload :BibliographyEntryDrop, "#{__dir__}/drop/bibliography_entry_drop"
|
|
26
|
+
autoload :BibliographyDrop, "#{__dir__}/drop/bibliography_drop"
|
|
27
|
+
autoload :TocEntryDrop, "#{__dir__}/drop/toc_entry_drop"
|
|
28
|
+
autoload :TocDrop, "#{__dir__}/drop/toc_drop"
|
|
29
|
+
autoload :DefinitionItemDrop, "#{__dir__}/drop/definition_item_drop"
|
|
30
|
+
autoload :DefinitionListDrop, "#{__dir__}/drop/definition_list_drop"
|
|
31
|
+
autoload :TermDrop, "#{__dir__}/drop/term_drop"
|
|
32
|
+
autoload :FootnoteDrop, "#{__dir__}/drop/footnote_drop"
|
|
33
|
+
autoload :TextContentDrop, "#{__dir__}/drop/text_content_drop"
|
|
34
|
+
autoload :DocumentDrop, "#{__dir__}/drop/document_drop"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Trigger eager load so every drop class body evaluates and self-registers.
|
|
40
|
+
Coridoc::Html::Drop::DropFactory.eager_load!
|