\n)
+ if date
+ result += %(\n)
+ result += %(\n"
+ result += "\n"
+ end
+ if url
+ scheme = Addressable::URI.parse(url).scheme&.downcase
+ if scheme
+ unless %w[http https].include? scheme
+ result += %(\n)
+ result += %(#{scheme}://\n)
+ result += "\n"
+ end
+ end
+ result += %(#{text}\n)
+ else
+ result += %(#{text}\n)
+ end
+ result += " — #{descr}\n" if descr
+ if alt_urls.any?
+ result += %[(#{
+ alt_urls.map do |alt_url|
+ %(#{alt_url[:name]})
+ end.join ', '
+ })\n]
+ end
+ result += '
'
+ result.freeze
+ end
+
+ def to_gemtext
+ result = ''
+ result += url ? "=> #{url}" : '*'
+ result += " #{index})"
+ result += " #{Date.parse(date)}" if date
+ result += " #{text}"
+ result += " #{EM_DASH} #{descr}" if descr
+ result.freeze
+ end
+
+ private
+
+ attr_writer :category, :slug, :index, :url,
+ :text, :descr, :date, :alt_urls
+ end
+ end
+end
diff --git a/lib/repubmark/elems/footnotes_category.rb b/lib/repubmark/elems/footnotes_category.rb
new file mode 100644
index 0000000..54aa4c9
--- /dev/null
+++ b/lib/repubmark/elems/footnotes_category.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module Repubmark
+ module Elems
+ class FootnotesCategory < Base
+ parents :Article
+
+ def initialize(parent, title)
+ super parent
+ @title = title
+ @footnotes = []
+ end
+
+ #################
+ # Basic methods #
+ #################
+
+ def to_html
+ <<~HTML
+
#@title
+
+
+ #{@footnotes.map(&:to_html).map(&:strip).join("\n")}
+
+ HTML
+ end
+
+ def to_gemtext
+ <<~GEMTEXT
+ ## #@title
+
+ #{@footnotes.map(&:to_gemtext).map(&:strip).join("\n")}
+ GEMTEXT
+ end
+
+ ###################
+ # Builder methods #
+ ###################
+
+ def footnote(**kwargs)
+ @footnotes << Footnote.new(self, **kwargs)
+ nil
+ end
+ end
+ end
+end