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 #
|
||||
##########################
|
||||
|
||||
def context(index, anchor)
|
||||
def context(index, category, slug)
|
||||
raise 'Context already given' if @context
|
||||
|
||||
@context = [index, anchor]
|
||||
@context = [index, category, slug]
|
||||
nil
|
||||
end
|
||||
|
||||
|
@ -115,8 +115,8 @@ module Repubmark
|
|||
ref_note(*@context)
|
||||
end
|
||||
|
||||
def ref_note(index, anchor)
|
||||
note Note.new self, index, anchor
|
||||
def ref_note(index, category, slug)
|
||||
note Note.new self, index, category, slug
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,10 +5,11 @@ module Repubmark
|
|||
class Note < Base
|
||||
parents :Joint
|
||||
|
||||
def initialize(parent, index, anchor)
|
||||
def initialize(parent, index, category, slug)
|
||||
super parent
|
||||
@index = index
|
||||
@anchor = anchor
|
||||
@category = category
|
||||
@slug = slug
|
||||
end
|
||||
|
||||
#################
|
||||
|
@ -18,7 +19,7 @@ module Repubmark
|
|||
def to_html
|
||||
[
|
||||
'<sup>',
|
||||
%(<a href="##{CGI.escape_html(@anchor)}">),
|
||||
%(<a href="##{CGI.escape_html(anchor)}">),
|
||||
%([#{CGI.escape_html(@index.to_s)}]),
|
||||
'</a>',
|
||||
'</sup>',
|
||||
|
@ -29,6 +30,8 @@ module Repubmark
|
|||
|
||||
private
|
||||
|
||||
def anchor = "#@category-#@slug"
|
||||
|
||||
def index_unicode_sup
|
||||
@index_unicode_sup ||= Repubmark.unicode_sup @index
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue