Skip to content

Commit

Permalink
🥔✨ Journal: Entry links to their Terms
Browse files Browse the repository at this point in the history
  • Loading branch information
zspencer committed Jul 13, 2023
1 parent 7d965ad commit 415606a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/furniture/journal/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ def autolink(link, link_type)
end

def postprocess(doc)
doc.gsub(/@([a-zA-Z\d]*)@(.*\.[a-zA-Z]*)/, '<a href="https://\2/@\1">@\1@\2</a>')
doc
.gsub(/@([a-zA-Z\d]*)@(.*\.[a-zA-Z]*)/, '<a href="https://\2/@\1">@\1@\2</a>')
.gsub(/#(\w+)/, '<a href="../terms/\1">#\1</a>')
end
end
end
5 changes: 3 additions & 2 deletions spec/furniture/journal/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
describe "#to_html" do
subject(:to_html) { entry.to_html }

context "when #body is 'https://www.google.com @[email protected]'" do
let(:entry) { build(:journal_entry, body: "https://www.google.com @[email protected]") }
context "when #body is 'https://www.google.com @[email protected] #GoodTimes'" do
let(:entry) { build(:journal_entry, body: "https://www.google.com @[email protected] #GoodTimes") }

it { is_expected.to include('<a href="https://www.google.com">https://www.google.com</a>') }
it { is_expected.to include('<a href="../terms/GoodTimes">#GoodTimes</a>') }
end
end

Expand Down

0 comments on commit 415606a

Please sign in to comment.