Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def block_code(code, language)
end

MARKDOWN_RENDERER = Redcarpet::Markdown.new(
MarkdownRenderer.new(filter_html: true, hard_wrap: true),
MarkdownRenderer.new(filter_html: true, hard_wrap: true, link_attributes: { 'data-turbo' => 'false' }),
fenced_code_blocks: true,
no_intra_emphasis: true,
autolink: true,
Expand Down
18 changes: 18 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'rails_helper'

RSpec.describe ApplicationHelper, type: :helper do
describe '#markdown' do
it 'opts explicit links out of Turbo so they escape a surrounding turbo-frame' do
html = helper.markdown('see [example](https://example.com)')

expect(html).to include('href="https://example.com"')
expect(html).to include('data-turbo="false"')
end

it 'applies the same attribute to autolinked bare URLs' do
html = helper.markdown('visit https://example.com now')

expect(html).to include('data-turbo="false"')
end
end
end
Loading