From b9543d846d9cb6bf6d4c7c61bf9ad35ada088445 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 11 Sep 2024 08:21:54 +0400 Subject: [PATCH] Note knows category and slug instead of just anchor --- lib/repubmark/elems/joint.rb | 8 ++++---- lib/repubmark/elems/note.rb | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/repubmark/elems/joint.rb b/lib/repubmark/elems/joint.rb index 5b11672..b48b463 100644 --- a/lib/repubmark/elems/joint.rb +++ b/lib/repubmark/elems/joint.rb @@ -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 diff --git a/lib/repubmark/elems/note.rb b/lib/repubmark/elems/note.rb index 1f4ef45..cb08247 100644 --- a/lib/repubmark/elems/note.rb +++ b/lib/repubmark/elems/note.rb @@ -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 [ '', - %(), + %(), %([#{CGI.escape_html(@index.to_s)}]), '', '', @@ -29,6 +30,8 @@ module Repubmark private + def anchor = "#@category-#@slug" + def index_unicode_sup @index_unicode_sup ||= Repubmark.unicode_sup @index end