about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-07-26 03:24:51 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:16 -0500
commitebc991b3059cfdac23e085c8333ae23d3f01a9de (patch)
tree0cf78c32a382222cc72ab050a25f582fe0baa178 /app/lib
parent1af0cdcd02de9e1dcfca78ac0c8aff209def980f (diff)
[Command Tags] Add TextTools module
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/command_tag/commands/text_tools.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/lib/command_tag/commands/text_tools.rb b/app/lib/command_tag/commands/text_tools.rb
new file mode 100644
index 000000000..acb0a5985
--- /dev/null
+++ b/app/lib/command_tag/commands/text_tools.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module CommandTag::Commands::TextTools
+  def handle_code_at_start(args)
+    name = args.count > 1 ? args[0] : 'code'
+
+    if @status.content_type == 'text/plain'
+      @vars[name] = ["----------\n#{args.present? ? args.last : nil}\n----------"]
+    else
+      @vars[name] = ["<pre><code>#{args.present? ? args.last : nil}</code></pre>"]
+    end
+  end
+end