Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/elixir/lib/io/ansi/docs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ defmodule IO.ANSI.Docs do

# Characters that can mark the beginning or the end of a word.
# Only support the most common ones at this moment.
@delimiters [?\s, ?', ?", ?!, ?@, ?#, ?$, ?%, ?^, ?&] ++
@delimiters [?\s, ?', ?", ?!, ??, ?,, ?:, ?;, ?/, ?@, ?#, ?$, ?%, ?^, ?&] ++
[?-, ?+, ?(, ?), ?[, ?], ?{, ?}, ?<, ?>, ?.]

### Inline start
Expand Down
17 changes: 17 additions & 0 deletions lib/elixir/test/elixir/io/ansi/docs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,23 @@ defmodule IO.ANSI.DocsTest do
assert result == "\e[36mhello world\e[0m\n\e[0m"
end

test "star/underscore works before punctuation" do
result = format_markdown("**hello world**,")
assert result == "\e[1mhello world\e[0m,\n\e[0m"

result = format_markdown("*hello world*;")
assert result == "\e[4mhello world\e[0m;\n\e[0m"

result = format_markdown("__hello world__:")
assert result == "\e[1mhello world\e[0m:\n\e[0m"

result = format_markdown("_hello world_?")
assert result == "\e[4mhello world\e[0m?\n\e[0m"

result = format_markdown("*hello world*/")
assert result == "\e[4mhello world\e[0m/\n\e[0m"
end

test "star/underscore/backtick works across words with ansi disabled" do
result = format_markdown("*hello world*", enabled: false)
assert result == "*hello world*"
Expand Down
Loading