From c10668a64f5530b0bb692c21ebf88301221d8d87 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 11 Sep 2024 08:34:15 +0400 Subject: [PATCH] Remove anchors --- lib/referator/reference.rb | 6 +----- test.rb | 20 ++++---------------- test/footnotes.html.erb | 4 ++-- test/footnotes.json.erb | 2 -- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/referator/reference.rb b/lib/referator/reference.rb index d15aa2f..1708ddd 100644 --- a/lib/referator/reference.rb +++ b/lib/referator/reference.rb @@ -12,11 +12,7 @@ module Referator end def to_h - @to_h ||= data.merge(category:, id:, slug:, anchor:).freeze - end - - def anchor - @anchor ||= "#{category}-#{slug}".freeze + @to_h ||= data.merge(category:, id:, slug:).freeze end private diff --git a/test.rb b/test.rb index 2b541a9..0319dfd 100755 --- a/test.rb +++ b/test.rb @@ -41,20 +41,12 @@ RAW_REFS = { REFS = { self: { - foo: RAW_REFS[:self][:foo].merge( - 'anchor' => 'self-blog-foo', - ).freeze, - bar: RAW_REFS[:self][:bar].merge( - 'anchor' => 'self-blog-bar', - ).freeze, + foo: RAW_REFS[:self][:foo], + bar: RAW_REFS[:self][:bar], }.freeze, link: { - example_com: RAW_REFS[:link][:example_com].merge( - 'anchor' => 'link-example-com', - ).freeze, - causa_arcana_com: RAW_REFS[:link][:causa_arcana_com].merge( - 'anchor' => 'link-causa-arcana-com', - ).freeze, + example_com: RAW_REFS[:link][:example_com], + causa_arcana_com: RAW_REFS[:link][:causa_arcana_com], }.freeze, }.freeze @@ -251,7 +243,6 @@ cmd :RENDER_FOOTNOTES, :json do |result| "category": "self", "id": "/blog/foo", "slug": "blog-foo", - "anchor": "self-blog-foo", "url": "/blog/foo.html", "text": "Foo" }, @@ -260,7 +251,6 @@ cmd :RENDER_FOOTNOTES, :json do |result| "category": "self", "id": "/blog/bar", "slug": "blog-bar", - "anchor": "self-blog-bar", "url": "/blog/bar.html", "text": "Bar" } @@ -271,7 +261,6 @@ cmd :RENDER_FOOTNOTES, :json do |result| "category": "link", "id": "example_com", "slug": "example-com", - "anchor": "link-example-com", "url": "https://example.com", "text": "Example Domain" }, @@ -280,7 +269,6 @@ cmd :RENDER_FOOTNOTES, :json do |result| "category": "link", "id": "causa_arcana_com", "slug": "causa-arcana-com", - "anchor": "link-causa-arcana-com", "url": "https://causa-arcana.com", "text": "Causa Arcana" } diff --git a/test/footnotes.html.erb b/test/footnotes.html.erb index ee8293b..a7c9d60 100644 --- a/test/footnotes.html.erb +++ b/test/footnotes.html.erb @@ -4,7 +4,7 @@
    <% notes['self'].each do |note| -%> -
  1. +
  2. " value="<%= note['index'] %>"> <%= note['text'] %>
  3. <% end -%> @@ -17,7 +17,7 @@
      <% notes['link'].each do |note| -%> -
    1. +
    2. " value="<%= note['index'] %>"> <%= note['text'] %>
    3. <% end -%> diff --git a/test/footnotes.json.erb b/test/footnotes.json.erb index d8c6b0c..4084e53 100644 --- a/test/footnotes.json.erb +++ b/test/footnotes.json.erb @@ -6,7 +6,6 @@ "category": "self", "id": <%= String(note['id']).to_json %>, "slug": <%= String(note['slug']).to_json %>, - "anchor": <%= String(note['anchor']).to_json %>, "url": <%= "#{note['id']}.html".to_json %>, "text": <%= String(note['text']).to_json %> }<%= ',' unless index == notes['self'].count - 1 %> @@ -19,7 +18,6 @@ "category": "link", "id": <%= String(note['id']).to_json %>, "slug": <%= String(note['slug']).to_json %>, - "anchor": <%= String(note['anchor']).to_json %>, "url": <%= String(note['url']).to_json %>, "text": <%= String(note['text']).to_json %> }<%= ',' unless index == notes['link'].count - 1 %>