Support for runnable kotlin snippets #3776#3801
Conversation
There are two different links for the Kotlin Playground, one for editing, the other for embedding Sample editing link https://pl.kotl.in/zYp4eGLeP Sample embedding link ``` {% kotlin https://pl.kotl.in/owreUFFUG?theme=darcula&from=3&to=6&readOnly=true %} ```
Zhao-Andy
left a comment
There was a problem hiding this comment.
Just one concern; everything else looks good!
|
@Zhao-Andy I am almost done. In particular, I learned from this issue how to always use the full embedded URL. JetBrains/kotlin-playground#64 Please advise me how to solve the one remaining problem because I'm getting frustrated
fails because it encodes the
|
|
Ah, that's a frustrating problem indeed. I just pushed some changes that were strictly linting issues. As for the encoding issue, we'd recommend sending the path with the parameters. So maybe instead of having a hash with each parameter, you can have a def self.parse_params(url, short)
query = url.query.nil? ? [] : URI.decode_www_form(url.query)
result = { short: short }
%i[from to theme readOnly].each do |param|
value = query.assoc(param.id2name)&.last
raise_error unless valid_param?(value)
end
result[:final_path] = url.to_s.gsub("&", "&").delete("https://#{url.host_name}")
# ...or something similar
end
# and then render final_path in the iframeThe HTML is encoded, but the Ruby strings that are passed along to the partial are not. |
|
@Zhao-Andy I tried it, doesn't work. |
Zhao-Andy
left a comment
There was a problem hiding this comment.
Looks good to me! I think that using the approval file with escaped & symbols is fine. @maestromac any thoughts?
|
@maestromac feel free to merge if looks good to you |
maestromac
left a comment
There was a problem hiding this comment.
Thanks for this PR! LGTM!
What type of PR is this? (check all applicable)
Description
Support runnable kotlin snippet
Demo: write a post with this content
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
The code above will look like this:
Documentation:
Related Tickets & Documents
#3776
https://jetbrains.github.io/kotlin-playground/examples/
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?