about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/lib/command_tag/commands/text_tools.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/lib/command_tag/commands/text_tools.rb b/app/lib/command_tag/commands/text_tools.rb
index 19f4b4f57..e004c7bec 100644
--- a/app/lib/command_tag/commands/text_tools.rb
+++ b/app/lib/command_tag/commands/text_tools.rb
@@ -2,8 +2,9 @@
 
 module CommandTag::Commands::TextTools
   def handle_code_at_start(args)
-    name = args.count > 1 ? args[0] : 'code'
+    return if args.count < 2
 
+    name = normalize(args[0])
     value = args.last.presence || ''
     @vars[name] = case @status.content_type
                   when 'text/markdown'
@@ -15,6 +16,20 @@ module CommandTag::Commands::TextTools
                   end
   end
 
+  def handle_code_with_return(args)
+    return if args.count > 1
+
+    value = args.last.presence || ''
+    case @status.content_type
+    when 'text/markdown'
+      ["```\n#{value}\n```"]
+    when 'text/html'
+      ["<pre><code>#{html_encode(value).gsub("\n", '<br/>')}</code></pre>"]
+    else
+      ["----------\n#{value}\n----------"]
+    end
+  end
+
   def handle_prepend_before_save(args)
     args.each { |arg| @text = "#{arg}\n#{text}" }
   end