Skip to content

Commit 4d5d8da

Browse files
authored
Merge pull request #528 from rspeicher/rs-asterisk-lists
Don't treat asterisks in list items as italic in Markdown
2 parents f37c511 + 168382b commit 4d5d8da

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* [#525](https://github.com/slack-ruby/slack-ruby-client/pull/525): Exclude spec files from gem package - [@amatsuda](https://github.com/amatsuda).
44
* [#527](https://github.com/slack-ruby/slack-ruby-client/pull/527): Explicitly require `racc` and `ostruct` - [@dblock](https://github.com/dblock).
5+
* [#528](https://github.com/slack-ruby/slack-ruby-client/pull/528): Don't treat asterisks in list items as italic in markdown - [@rspeicher](https://github.com/rspeicher).
56
* Your contribution here.
67

78
### 2.4.0 (2024/07/14)

lib/slack/messages/formatting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def url_link(text, url)
7575
#
7676
def markdown(text)
7777
text
78-
.gsub(/(?<!\*)\*([^*]+)\*(?!\*)/, '_\1_') # italic
78+
.gsub(/(?<!\*)\*([^*\n]+)\*(?!\*)/, '_\1_') # italic
7979
.gsub(/\*\*\*(.*?)\*\*\*/, '*_\1_*') # bold & italic
8080
.gsub(/\*\*(.*?)\*\*/, '*\1*') # bold
8181
.gsub(/~~(.*?)~~/, '~\1~') # strikethrough

spec/slack/messages/formatting_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@
149149
)
150150
end
151151

152+
it "doesn't treat list items as text formatting" do
153+
msg = <<~MSG
154+
Une liste:
155+
156+
* Article 1
157+
* Article 2
158+
* Article 3
159+
MSG
160+
161+
expect(formatting.markdown(msg)).to eq msg
162+
end
163+
152164
it "doesn't format other markdown" do
153165
expect(formatting.markdown('## A heading\n_Italics_\n`code`')).to eq '## A heading\n_Italics_\n`code`'
154166
end

0 commit comments

Comments
 (0)