From a38edbfcec7f2db247c6328ec84c9b81a29617e4 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Thu, 30 Jul 2020 13:39:06 -0500 Subject: [Command Tags] Use return template with code command --- app/lib/command_tag/commands/text_tools.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'app') 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' + ["
#{html_encode(value).gsub("\n", '
')}
"] + else + ["----------\n#{value}\n----------"] + end + end + def handle_prepend_before_save(args) args.each { |arg| @text = "#{arg}\n#{text}" } end -- cgit