Skip to content

Commit b82c44a

Browse files
authored
Update most common delimeters in Markdown ANSI rendering (#15564)
1 parent 1cb2089 commit b82c44a

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

lib/elixir/lib/io/ansi/docs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ defmodule IO.ANSI.Docs do
673673

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

679679
### Inline start

lib/elixir/test/elixir/io/ansi/docs_test.exs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ defmodule IO.ANSI.DocsTest do
317317
assert result == "\e[36mhello world\e[0m\n\e[0m"
318318
end
319319

320+
test "star/underscore works before punctuation" do
321+
result = format_markdown("**hello world**,")
322+
assert result == "\e[1mhello world\e[0m,\n\e[0m"
323+
324+
result = format_markdown("*hello world*;")
325+
assert result == "\e[4mhello world\e[0m;\n\e[0m"
326+
327+
result = format_markdown("__hello world__:")
328+
assert result == "\e[1mhello world\e[0m:\n\e[0m"
329+
330+
result = format_markdown("_hello world_?")
331+
assert result == "\e[4mhello world\e[0m?\n\e[0m"
332+
333+
result = format_markdown("*hello world*/")
334+
assert result == "\e[4mhello world\e[0m/\n\e[0m"
335+
end
336+
320337
test "star/underscore/backtick works across words with ansi disabled" do
321338
result = format_markdown("*hello world*", enabled: false)
322339
assert result == "*hello world*"

0 commit comments

Comments
 (0)