Note knows category and slug instead of just anchor
This commit is contained in:
parent
3a3bee771a
commit
b9543d846d
2 changed files with 10 additions and 7 deletions
|
@ -100,10 +100,10 @@ module Repubmark
|
||||||
# Builder methods: Notes #
|
# Builder methods: Notes #
|
||||||
##########################
|
##########################
|
||||||
|
|
||||||
def context(index, anchor)
|
def context(index, category, slug)
|
||||||
raise 'Context already given' if @context
|
raise 'Context already given' if @context
|
||||||
|
|
||||||
@context = [index, anchor]
|
@context = [index, category, slug]
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ module Repubmark
|
||||||
ref_note(*@context)
|
ref_note(*@context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ref_note(index, anchor)
|
def ref_note(index, category, slug)
|
||||||
note Note.new self, index, anchor
|
note Note.new self, index, category, slug
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -5,10 +5,11 @@ module Repubmark
|
||||||
class Note < Base
|
class Note < Base
|
||||||
parents :Joint
|
parents :Joint
|
||||||
|
|
||||||
def initialize(parent, index, anchor)
|
def initialize(parent, index, category, slug)
|
||||||
super parent
|
super parent
|
||||||
@index = index
|
@index = index
|
||||||
@anchor = anchor
|
@category = category
|
||||||
|
@slug = slug
|
||||||
end
|
end
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
@ -18,7 +19,7 @@ module Repubmark
|
||||||
def to_html
|
def to_html
|
||||||
[
|
[
|
||||||
'<sup>',
|
'<sup>',
|
||||||
%(<a href="##{CGI.escape_html(@anchor)}">),
|
%(<a href="##{CGI.escape_html(anchor)}">),
|
||||||
%([#{CGI.escape_html(@index.to_s)}]),
|
%([#{CGI.escape_html(@index.to_s)}]),
|
||||||
'</a>',
|
'</a>',
|
||||||
'</sup>',
|
'</sup>',
|
||||||
|
@ -29,6 +30,8 @@ module Repubmark
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def anchor = "#@category-#@slug"
|
||||||
|
|
||||||
def index_unicode_sup
|
def index_unicode_sup
|
||||||
@index_unicode_sup ||= Repubmark.unicode_sup @index
|
@index_unicode_sup ||= Repubmark.unicode_sup @index
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue