hotdocs 0.4.0 → 0.7.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.
@@ -1,92 +0,0 @@
1
- module Kramdown
2
- class Element
3
- def to_h
4
- {
5
- children: children.map(&:to_h),
6
- type:,
7
- value:
8
- }
9
- end
10
- end
11
- end
12
-
13
- module Alert
14
- PATHS_BY_ALERT_TYPE = {
15
- "danger" => [
16
- "M15.362 5.214A8.252 8.252 0 0 1 12 21 8.25 8.25 0 0 1 6.038 7.047 8.287 8.287 0 0 0 9 9.601a8.983 8.983 0 0 1 3.361-6.867 8.21 8.21 0 0 0 3 2.48Z",
17
- "M12 18a3.75 3.75 0 0 0 .495-7.468 5.99 5.99 0 0 0-1.925 3.547 5.975 5.975 0 0 1-2.133-1.001A3.75 3.75 0 0 0 12 18Z"
18
- ],
19
- "warning" => [
20
- "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"
21
- ],
22
- "tip" => [
23
- "M12 18v-5.25m0 0a6.01 6.01 0 0 0 1.5-.189m-1.5.189a6.01 6.01 0 0 1-1.5-.189m3.75 7.478a12.06 12.06 0 0 1-4.5 0m3.75 2.383a14.406 14.406 0 0 1-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 1 0-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"
24
- ],
25
- "info" => [
26
- "m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"
27
- ]
28
- }
29
-
30
- def convert_blockquote(el, indent)
31
- child = el.children[0]
32
-
33
- case child.to_h
34
- in {
35
- type: :p,
36
- children: [
37
- { type: :text, value: /\A\[!(INFO|TIP|WARNING|DANGER)\]\z/ },
38
- { type: :br },
39
- *
40
- ]
41
- }
42
- alert_type = $+.downcase
43
- child.children.slice!(0, 2) # remove :text & :br
44
-
45
- svg = Kramdown::Element.new(
46
- :html_element,
47
- :svg,
48
- {
49
- class: "alert__icon",
50
- xmlns: "http://www.w3.org/2000/svg",
51
- fill: "none",
52
- viewBox: "0 0 24 24",
53
- "stroke-width": "1.5",
54
- stroke: "currentColor"
55
- }
56
- )
57
-
58
- PATHS_BY_ALERT_TYPE[alert_type].each do |path|
59
- svg.children << Kramdown::Element.new(:html_element, :path, {
60
- "stroke-linecap": "round",
61
- "stroke-linejoin": "round",
62
- d: path
63
- })
64
- end
65
-
66
- label = Kramdown::Element.new(:html_element, :span, { class: "alert__label" })
67
- label.children << Kramdown::Element.new(:text, alert_type.upcase)
68
-
69
- header = Kramdown::Element.new(:html_element, :div, { class: "alert__header" })
70
- header.children << svg
71
- header.children << label
72
-
73
- content = Kramdown::Element.new(:html_element, :div, { class: "alert__content" })
74
- content.children.push(*el.children)
75
-
76
- alert = Kramdown::Element.new(:html_element, :div, {})
77
- alert.children << header
78
- alert.children << content
79
-
80
- format_as_block_html(
81
- "div",
82
- { class: "alert alert--#{alert_type}" },
83
- format_as_indented_block_html("div", {}, inner(alert, indent), indent),
84
- indent
85
- )
86
- else
87
- super
88
- end
89
- end
90
- end
91
-
92
- Kramdown::Converter::Html.prepend(Alert)