Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced dashes with dots to support bulleted list as it requires a b… #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/slack_mrkdwn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions spec/fixtures/expectation/basic_fixture_expectation
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/slack_mrkdwn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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|
Expand Down