38 lines
713 B
Ruby
38 lines
713 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Repubmark
|
|
module Elems
|
|
class Note < Base
|
|
parents :Joint
|
|
|
|
def initialize(parent, index, anchor)
|
|
super parent
|
|
@index = index
|
|
@anchor = anchor
|
|
end
|
|
|
|
#################
|
|
# Basic methods #
|
|
#################
|
|
|
|
def to_html
|
|
[
|
|
'<sup>',
|
|
%(<a href="##{CGI.escape_html(@anchor)}">),
|
|
%([#{CGI.escape_html(@index.to_s)}]),
|
|
'</a>',
|
|
'</sup>',
|
|
].join.freeze
|
|
end
|
|
|
|
def to_gemtext = "⁽#{index_unicode_sup}⁾".freeze
|
|
|
|
private
|
|
|
|
def index_unicode_sup
|
|
@index_unicode_sup ||= Repubmark.unicode_sup @index
|
|
end
|
|
end
|
|
end
|
|
end
|