Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
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
3 changes: 2 additions & 1 deletion app/liquid_tags/runkit_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def initialize(_tag_name, markup, _parse_context)

def render(context)
content = Nokogiri::HTML.parse(super)
parsed_content = content.xpath("//html/body").text
# Get the inner HTML instead of just text to preserve HTML tags
parsed_content = content.xpath("//html/body").inner_html
ApplicationController.render(
partial: PARTIAL,
locals: {
Expand Down
21 changes: 21 additions & 0 deletions spec/liquid_tags/runkit_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
CODE
end

let(:content_with_html) do
<<~CODE
const { ValueViewerSymbol } = require("@runkit/value-viewer");

const myCustomObject = {
[ValueViewerSymbol]: {
title: "My First Viewer",
HTML: "<marquee>🍔Hello, World!🍔</marquee>"
}
};
CODE
end

def generate_runkit_liquid(preamble_str, block)
Liquid::Template.register_tag("runkit", described_class)
Liquid::Template.parse("{% runkit #{preamble_str}%}#{block}{% endrunkit %}")
Expand All @@ -31,5 +44,13 @@ def generate_runkit_liquid(preamble_str, block)
expect(rendered).to include('await getJSON(&quot;https://storage.googleapis.com/maps-devrel/google.json&quot;);')
# rubocop:enable Style/StringLiterals
end

it "preserves HTML tags in content" do
rendered = generate_runkit_liquid(preamble, content_with_html).render

# Check that the HTML tags are preserved
expect(rendered).to include('&lt;marquee&gt;🍔Hello, World!🍔&lt;/marquee&gt;')
expect(rendered).not_to include('🍔Hello, World!🍔') # This would indicate HTML was stripped
end
end
end
Loading