Skip to content

Commit

Permalink
fix(genCrystalExample): use heredoc instead of literal
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Oct 14, 2021
1 parent ff6dc4b commit 8616767
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
function genCrystalExample(code) {
const mainStruct = code.match(/struct (?<struct>O_.+)\n/)?.groups?.struct;
const res = ['require "json"', `${code}`];
res.push(`\npp ${mainStruct}.from_json(%(${JSON.stringify(JSON.parse(input))}))`);
res.push(`input = <<-JSON\n${JSON.stringify(JSON.parse(input))}\nJSON`);
res.push(`pp ${mainStruct}.from_json(input)`);
return res.join('\n\n');
}
Expand Down

0 comments on commit 8616767

Please sign in to comment.