From beb6a68a959c5fe489dc3957bd4a12a0556d4cf5 Mon Sep 17 00:00:00 2001 From: Jack Baldry Date: Thu, 27 Jun 2024 08:20:07 +0100 Subject: [PATCH] Ensure {{exec}} has precedence over {{copy}} Signed-off-by: Jack Baldry --- .../transformer/goldmark/renderer/markdown/block.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/transformer/goldmark/renderer/markdown/block.go b/tools/transformer/goldmark/renderer/markdown/block.go index 2215f53..f253711 100644 --- a/tools/transformer/goldmark/renderer/markdown/block.go +++ b/tools/transformer/goldmark/renderer/markdown/block.go @@ -65,13 +65,18 @@ func (r *Renderer) renderFencedCodeBlock(w util.BufWriter, source []byte, node a r.write(w, "```") if r.Config.KillercodaActions { - if _, ok := n.AttributeString("data-killercoda-exec"); ok { - r.write(w, "{{exec}}") - } + var action string if _, ok := n.AttributeString("data-killercoda-copy"); ok { - r.write(w, "{{copy}}") + action = "{{copy}}" + } + + // exec takes precedence over copy. + if _, ok := n.AttributeString("data-killercoda-exec"); ok { + action = "{{exec}}" } + + r.write(w, action) } r.write(w, '\n')