From 8e7c3665e0d53703ff5b0a52db145dfb1fb29ca8 Mon Sep 17 00:00:00 2001 From: syedminim Date: Fri, 5 Jul 2024 23:03:33 +0500 Subject: [PATCH] Replaced dashes with dots to support bulleted list as it requires a bullet symbol --- lib/slack_mrkdwn.rb | 6 +++--- spec/fixtures/expectation/basic_fixture_expectation | 8 ++++---- spec/slack_mrkdwn_spec.rb | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/slack_mrkdwn.rb b/lib/slack_mrkdwn.rb index b66d3ed..f7520e9 100644 --- a/lib/slack_mrkdwn.rb +++ b/lib/slack_mrkdwn.rb @@ -133,12 +133,12 @@ def format_list(entries, style) when :ordered number_list(entries) when :unordered - add_dashes(entries) + add_dots(entries) end end - def add_dashes(entries) - entries.gsub(/^(\S+.*)$/, '- \1') + def add_dots(entries) + entries.gsub(/^(\S+.*)$/, '• \1') end def number_list(entries) diff --git a/spec/fixtures/expectation/basic_fixture_expectation b/spec/fixtures/expectation/basic_fixture_expectation index 3dbfcbc..5676ca3 100644 --- a/spec/fixtures/expectation/basic_fixture_expectation +++ b/spec/fixtures/expectation/basic_fixture_expectation @@ -33,7 +33,7 @@ My text content describing my list! Here's the list: 1. First ordered list item 2. Another item - - Unordered sub-list. + • Unordered sub-list. 3. Actual numbers don't matter, just that it's a number 1. Ordered sub-list 4. And another item. @@ -44,9 +44,9 @@ My text content describing my list! Here's the list: Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.) -- Unordered list can use asterisks -- Or minuses -- Or pluses +• Unordered list can use asterisks +• Or minuses +• Or pluses --- Images https://example.com/image.png diff --git a/spec/slack_mrkdwn_spec.rb b/spec/slack_mrkdwn_spec.rb index 3f8c7f5..fcd2bc7 100644 --- a/spec/slack_mrkdwn_spec.rb +++ b/spec/slack_mrkdwn_spec.rb @@ -13,7 +13,7 @@ Test.new('converts combined emphasis', 'Combined emphasis with **asterisks and _underscores_**.', 'Combined emphasis with *asterisks and _underscores_*.'), Test.new('converts strike-through', '~~Crossed out~~ content', '~Crossed out~ content'), Test.new('converts codeblocks', "```javascript\nconsole.log('Hello, World!')\n```", "```\nconsole.log('Hello, World!')\n```"), - Test.new('converts unordered lists', "+ List with plus symbol\n* Or asterisk\n- Or minus symbol\n\t+ Even indented lists", "- List with plus symbol\n- Or asterisk\n- Or minus symbol\n - Even indented lists"), + Test.new('converts unordered lists', "+ List with plus symbol\n* Or asterisk\n- Or minus symbol\n\t+ Even indented lists", "• List with plus symbol\n• Or asterisk\n• Or minus symbol\n • Even indented lists"), Test.new('converts ordered lists', "1. First element\n1. Second element\n1. Third element", "1. First element\n2. Second element\n3. Third element"), Test.new('converts nested lists', "1. First element\n 1. Nested element\n 1. Another nested element\n1. Second element\n1. Third element", "1. First element\n 1. Nested element\n 2. Another nested element\n2. Second element\n3. Third element"), Test.new('converts image', "![](https://example.com/image.png)", 'https://example.com/image.png'), @@ -27,7 +27,7 @@ Test.new('preserves leading spaces', " Aligned text content", " Aligned text content"), Test.new('preserves paragraphs', 'My paragraph looks the same!', 'My paragraph looks the same!'), Test.new('preserves spacing between paragraphs', "My first paragraph!\n\nFollowed by another paragraph!", "My first paragraph!\n\nFollowed by another paragraph!"), - Test.new('preserves spacing between lists and paragraphs', "Description of list:\n\n* List Element\n+ Another list element\n\nFollow up paragraph.", "Description of list:\n\n- List Element\n- Another list element\n\nFollow up paragraph."), + Test.new('preserves spacing between lists and paragraphs', "Description of list:\n\n* List Element\n+ Another list element\n\nFollow up paragraph.", "Description of list:\n\n• List Element\n• Another list element\n\nFollow up paragraph."), ] tests.each do |t|