bluedoc-sml 0.8.1 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c30834de730fc0b91f692e1f10ce1ae164db8a3581403ed15246f7dfab868631
4
- data.tar.gz: a947c59b093ddcbe7c145e4bd4f43284ce9c321beeffaa3e02ea5f65edaa4e1d
3
+ metadata.gz: 1aed464d55d58e5bc7f34bb4a86d7f0b5d8ca23c5323cdb49992a3536c41bb9b
4
+ data.tar.gz: 5e50a22dc3b84817d036347ca595129e364cce421aa76f5e3daf6b9bba8f821a
5
5
  SHA512:
6
- metadata.gz: 504efae7d193c057b299818f1149088fa7099e9fe92cf81dff99a83c273e07b95aafa206cec82c467007f0b3509808f3894605fe4b607971f2a038a856c7e182
7
- data.tar.gz: 1c31691b13a0c91dad1d43c7b2ac81ac016930798b92c39f5de88da07c22cfa8cbaf6bcf531ace6bb7fc18e4d42e84f91dd2ff17af1126b52b5678142111dabc
6
+ metadata.gz: 3c73f6b68eca4cc63435fe6d319d53352c23510e2dfc1842cf510481c32360b35d2aa022805e2963e473319e8be847f9bf09b4d7b4e1393ce0f2399d23d11348
7
+ data.tar.gz: 802b687d07deff3fe3406e29fbb8e9c11e7eb4e6dbcf1c1713cc83e3e74b35cfb8fe35945ca193dbc79f521bb34cdedc044b08414d9ca345387b2c443029c57b
@@ -32,6 +32,16 @@ module BlueDoc::SML::Rules
32
32
  end
33
33
 
34
34
  protected
35
+ def self.name_by_attrs(attrs)
36
+ attrs ||= {}
37
+
38
+ if !attrs[:nid]
39
+ return ""
40
+ end
41
+
42
+ return %( nid="#{attrs[:nid]}")
43
+ end
44
+
35
45
  def self.style_for_attrs(attrs, style = {})
36
46
  attrs ||= {}
37
47
  if attrs[:align]
@@ -66,7 +76,7 @@ module BlueDoc::SML::Rules
66
76
  style.map { |k, v| "#{k}: #{v};" }.join(" ")
67
77
  end
68
78
 
69
- def self.html_attrs(attrs)
79
+ def self.html_attrs(attrs, style_attr = nil)
70
80
  attrs[:width] = nil if attrs[:width].to_i == 0
71
81
  attrs[:height] = nil if attrs[:height].to_i == 0
72
82
 
@@ -12,7 +12,9 @@ module BlueDoc::SML::Rules
12
12
 
13
13
  children = renderer.children_to_html(node)
14
14
 
15
- %(<blockquote>#{children}</blockquote>)
15
+ nid_attr = name_by_attrs(attrs)
16
+
17
+ %(<blockquote#{nid_attr}>#{children}</blockquote>)
16
18
  end
17
19
  end
18
20
  end
@@ -19,7 +19,9 @@ module BlueDoc::SML::Rules
19
19
  language = attrs[:language]
20
20
  code = attrs[:code] || ""
21
21
 
22
- block_code(code, language)
22
+ nid_attr = name_by_attrs(attrs)
23
+ html = block_code(code, language)
24
+ html.sub(%(class="highlight"), %(class="highlight"#{nid_attr}))
23
25
  end
24
26
  end
25
27
  end
@@ -20,8 +20,9 @@ module BlueDoc::SML::Rules
20
20
 
21
21
  file_type = (::File.extname(attrs[:name]) || "none").sub(".", "")
22
22
 
23
+ nid_attr = name_by_attrs(attrs)
23
24
  out = <<~HTML
24
- <a class="attachment-file" title="#{attrs[:name]}" target="_blank" href="#{attrs[:src]}">
25
+ <a class="attachment-file" title="#{attrs[:name]}" target="_blank" href="#{attrs[:src]}"#{nid_attr}>
25
26
  <span class="icon-box"><i class="fas fa-file fa-#{file_type}-file"></i></span>
26
27
  <span class="filename">#{escape_html(attrs[:name])}</span>
27
28
  <span class="filesize">#{escape_html(humanize_size)}</span>
@@ -21,10 +21,13 @@ module BlueDoc::SML::Rules
21
21
  header_id = Digest::MD5.hexdigest(title.strip)[0..8]
22
22
  end
23
23
 
24
+ attrs = attributes(node)
25
+ nid_attr = name_by_attrs(attrs)
26
+
24
27
  if title.blank?
25
- %(<#{heading_tag}>#{title}</#{heading_tag}>)
28
+ %(<#{heading_tag}#{nid_attr}>#{title}</#{heading_tag}>)
26
29
  else
27
- %(<#{heading_tag} id="#{header_id}"><a href="##{header_id}" class="heading-anchor">#</a>#{title}</#{heading_tag}>)
30
+ %(<#{heading_tag} id="#{header_id}"#{nid_attr}><a href="##{header_id}" class="heading-anchor">#</a>#{title}</#{heading_tag}>)
28
31
  end
29
32
  end
30
33
  end
@@ -19,6 +19,7 @@ module BlueDoc::SML::Rules
19
19
 
20
20
  return "" if !current
21
21
  return "" if opts[:next] && nid == attributes(opts[:next])[:nid]
22
+ nid_attr = name_by_attrs(attrs)
22
23
 
23
24
  current.length.times do |i|
24
25
  current_node = current[i]
@@ -56,8 +57,10 @@ module BlueDoc::SML::Rules
56
57
  current_tag != prev_tag
57
58
  )
58
59
  )
60
+ tag_attr = %( data-level="#{current_level}")
61
+ tag_attr += nid_attr if current_level == 1
59
62
 
60
- html << %(<#{current_tag} data-level="#{current_level}">)
63
+ html << %(<#{current_tag}#{tag_attr}>)
61
64
  end
62
65
 
63
66
  children = renderer.children_to_html(current_node)
@@ -94,80 +97,5 @@ module BlueDoc::SML::Rules
94
97
 
95
98
  html.join("\n")
96
99
  end
97
-
98
- def self.to_html1(node, opts = {})
99
- renderer = opts[:renderer]
100
- attrs = attributes(node)
101
- children = renderer.children_to_html(node)
102
-
103
- # Normal paragraph data
104
- text_align = attrs[:align] || "left"
105
- indent = attrs[:indent]
106
- text_indent = indent && indent[:firstline]
107
- indent_left = indent ? indent[:left] : 0
108
-
109
- # List style
110
- nid = attrs[:nid]
111
- list_type = attrs[:type] || "bulleted"
112
- level = attrs[:level] || 1
113
- num = (attrs[:num] || 0) + 1
114
-
115
- style_attrs = style_for_attrs(attrs,
116
- "padding-left": "#{indent_left * INDENT_PX}px"
117
- )
118
-
119
- wrap_tag = list_type == "bulleted" ? "ul" : "ol"
120
-
121
-
122
- # <ul>
123
- # <li>Bold text</li>
124
- # <li>Important text
125
- # <ul>
126
- # <li>Emphasized text</li>
127
- # <li>
128
- # Small text
129
- # <ul>
130
- # <li>Subscript text</li>
131
- # </ul>
132
- # </li>
133
- # </ul>
134
- # </li>
135
- # </ul>
136
-
137
- # get prev attrs
138
- prev_name = tag_name(opts[:prev])
139
- next_name = tag_name(opts[:next])
140
- prev_level = attributes(opts[:prev])[:level]
141
- next_level = attributes(opts[:next])[:level]
142
-
143
- outs = []
144
-
145
-
146
- if prev_name != "list" || prev_level != level
147
- outs << %(<#{wrap_tag} data-level="#{level}">)
148
- end
149
-
150
- li_item = "<li>#{children}"
151
-
152
- if next_name == "list"
153
- if next_level < level
154
- (level - next_level + 1).times do
155
- li_item += "</li></#{wrap_tag}>"
156
- end
157
- elsif next_level == level
158
- li_item += "</li>"
159
- else
160
- li_item += "\n"
161
- end
162
- else
163
- (level - 1 + 1).times do
164
- li_item += "</li></#{wrap_tag}>"
165
- end
166
- end
167
-
168
- outs << li_item
169
-
170
- outs.join("\n")
171
- end
172
100
  end
173
101
  end
@@ -12,8 +12,8 @@ module BlueDoc::SML::Rules
12
12
  attrs = attributes(node)
13
13
 
14
14
  style_attrs = style_for_attrs(attrs)
15
-
16
- %(<p#{style_attrs}>#{children}</p>)
15
+ nid_attr = name_by_attrs(attrs)
16
+ %(<p#{style_attrs}#{nid_attr}>#{children}</p>)
17
17
  end
18
18
  end
19
19
  end
@@ -14,7 +14,8 @@ module BlueDoc::SML::Rules
14
14
  return "" if code.blank?
15
15
 
16
16
  svg_code = BlueDoc::Plantuml.encode(code)
17
- %(<img src="#{renderer.config.plantuml_service_host}/svg/#{svg_code}" class="plantuml-image" />)
17
+ nid_attr = name_by_attrs(attrs)
18
+ %(<div#{nid_attr}><img src="#{renderer.config.plantuml_service_host}/svg/#{svg_code}" class="plantuml-image" /></div>)
18
19
  end
19
20
  end
20
21
  end
@@ -9,8 +9,10 @@ module BlueDoc::SML::Rules
9
9
  def self.to_html(node, opts = {})
10
10
  renderer = opts[:renderer]
11
11
  children = renderer.children_to_html(node)
12
+ attrs = attributes(node)
13
+ nid_attr = name_by_attrs(attrs)
12
14
 
13
- %(<table>#{children}</table>)
15
+ %(<table#{nid_attr}>#{children}</table>)
14
16
  end
15
17
  end
16
18
  end
@@ -20,8 +20,10 @@ module BlueDoc::SML::Rules
20
20
  width: width
21
21
  )
22
22
 
23
+ nid_attr = name_by_attrs(attrs)
24
+
23
25
  out = <<~HTML
24
- <video controls preload="no"#{video_attrs}>
26
+ <video controls preload="no"#{video_attrs}#{nid_attr}>
25
27
  <source src="#{attrs[:src]}" type="#{attrs[:type]}">
26
28
  </video>
27
29
  HTML
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BlueDoc
4
4
  module SML
5
- VERSION = "0.8.1"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bluedoc-sml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-17 00:00:00.000000000 Z
11
+ date: 2019-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport