fix: Parsing of preamble with escaped content in runkit tags (#11466)
This commit is contained in:
parent
68b320a1de
commit
ebd7712829
3 changed files with 58 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<div class="runkit-element">
|
||||
<code style="display: none">
|
||||
<%= preamble %>
|
||||
<%= CGI.unescapeHTML preamble %>
|
||||
</code>
|
||||
<code style="display: none;">
|
||||
<%= parsed_content %>
|
||||
|
|
|
|||
45
spec/fixtures/files/article_with_runkit_tag_with_preamble.txt
vendored
Normal file
45
spec/fixtures/files/article_with_runkit_tag_with_preamble.txt
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
title: Sample Article
|
||||
published: true
|
||||
description: this is a sample article
|
||||
tags: test
|
||||
---
|
||||
|
||||
Suspendisse ac lobortis velit, a feugiat sapien. Aenean condimentum, nulla at fermentum sagittis, tellus nisi suscipit velit, vel sollicitudin odio ligula a odio. Integer eget efficitur massa, in sodales velit. Nunc fermentum consequat scelerisque. Morbi elementum tristique faucibus. Nulla vel lectus non justo euismod varius. Vivamus id nisl sit amet odio tincidunt fringilla. Pellentesque odio odio, vulputate in risus eu, lacinia porttitor lorem. Nunc posuere tempus est, imperdiet suscipit odio maximus id. Nam eget feugiat magna.
|
||||
|
||||
{% runkit %}
|
||||
const node = data => next => callback => callback (data) (next)
|
||||
// ---- ---- -------- ---- ----
|
||||
// \ | / / /
|
||||
// parameters are curried -------------
|
||||
// /
|
||||
// closures make data and next available
|
||||
// to callback when it is finally called.
|
||||
|
||||
// I can use bind to store my data and next values.
|
||||
const head = node ('data') (null)
|
||||
// ------ ----
|
||||
// / /
|
||||
// We can partially apply the arguments `data` and null.
|
||||
|
||||
// Use a callback to read the values from head.
|
||||
head (data => next => {
|
||||
return { data, next }
|
||||
})
|
||||
{% endrunkit %}
|
||||
|
||||
|
||||
{% runkit
|
||||
const V = a => b => c => c (a) (b)
|
||||
%}
|
||||
const node = V
|
||||
|
||||
const leftRight = node ('Left') ('Right')
|
||||
|
||||
// TODO: modify callback so the code returns 'Left'
|
||||
const callback = a => b => {}
|
||||
|
||||
leftRight (callback) //=> 'Left'
|
||||
{% endrunkit %}
|
||||
|
||||
|
||||
|
|
@ -8,6 +8,9 @@ RSpec.describe "Creating an article with the editor", type: :system do
|
|||
let!(:template_with_runkit_tag) do
|
||||
file_fixture("article_with_runkit_tag.txt").read
|
||||
end
|
||||
let!(:template_with_runkit_tag_with_preamble) do
|
||||
file_fixture("article_with_runkit_tag_with_preamble.txt").read
|
||||
end
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
|
|
@ -44,6 +47,15 @@ RSpec.describe "Creating an article with the editor", type: :system do
|
|||
expect_runkit_tag_to_be_active
|
||||
end
|
||||
|
||||
it "creates a new article with a Runkit tag with complex preamble" do
|
||||
visit new_path
|
||||
fill_in "article_body_markdown", with: ""
|
||||
fill_in "article_body_markdown", with: template_with_runkit_tag_with_preamble
|
||||
click_button "Save changes"
|
||||
|
||||
expect_runkit_tag_to_be_active(count: 2)
|
||||
end
|
||||
|
||||
# TODO: [@forem/sre] figure out why this fails intermittently :-|
|
||||
xit "previews article with a Runkit tag and creates it" do
|
||||
visit new_path
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue