A Markdown shard for the Crystal programming language
リビジョン | 7e2c36ae62754b847c5baa3ebae529d0c25ab287 (tree) |
---|---|
日時 | 2023-12-28 10:54:19 |
作者 | supercell <stigma@disr...> |
コミッター | supercell |
Merge branch 'solvin-master'
@@ -20,13 +20,13 @@ module Luce | ||
20 | 20 | class Element < Node |
21 | 21 | getter tag : String |
22 | 22 | getter children : Array(Node)? |
23 | - getter attributes : Hash(String, String) | |
23 | + getter attributes : Hash(String, String?) | |
24 | 24 | property generated_id : String? |
25 | 25 | property footnote_label : String? |
26 | 26 | |
27 | 27 | # Initializes a *tag* Element with *children*. |
28 | 28 | def initialize(@tag : String, @children : Array(Node)?) |
29 | - @attributes = Hash(String, String).new | |
29 | + @attributes = Hash(String, String?).new | |
30 | 30 | end |
31 | 31 | |
32 | 32 | # Initializes an empty, self-closing *tag* element. |
@@ -158,8 +158,8 @@ module Luce | ||
158 | 158 | ordinal["fn-#{footnote_labels[i]}"] = i |
159 | 159 | end |
160 | 160 | footnotes.sort! do |l, r| |
161 | - idl = l.attributes["id"]? ? l.attributes["id"].downcase : "" | |
162 | - idr = r.attributes["id"]? ? r.attributes["id"].downcase : "" | |
161 | + idl = l.attributes["id"]? ? l.attributes["id"].to_s.downcase : "" | |
162 | + idr = r.attributes["id"]? ? r.attributes["id"].to_s.downcase : "" | |
163 | 163 | (ordinal[idl]? || 0) - (ordinal[idr]? || 0) |
164 | 164 | end |
165 | 165 | list = Element.new("ol", footnotes + [] of Node) |
@@ -100,7 +100,11 @@ module Luce | ||
100 | 100 | buffer << "<#{element.tag}" |
101 | 101 | |
102 | 102 | element.attributes.each do |key, value| |
103 | - buffer << " #{key}=\"#{value}\"" | |
103 | + if v = value | |
104 | + buffer << " #{key}=\"#{v}\"" | |
105 | + else | |
106 | + buffer << " #{key}" | |
107 | + end | |
104 | 108 | end |
105 | 109 | |
106 | 110 | generated_id = element.generated_id |