From de9a62706bbdcfe2ca2a0f8db306ac4b4efc8329 Mon Sep 17 00:00:00 2001 From: Alex Gubarev Date: Thu, 9 Jul 2026 17:15:20 +0300 Subject: [PATCH] update most common delims + tests --- lib/elixir/lib/io/ansi/docs.ex | 2 +- lib/elixir/test/elixir/io/ansi/docs_test.exs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/elixir/lib/io/ansi/docs.ex b/lib/elixir/lib/io/ansi/docs.ex index fe3a04bc1e4..9ee62feab8a 100644 --- a/lib/elixir/lib/io/ansi/docs.ex +++ b/lib/elixir/lib/io/ansi/docs.ex @@ -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 diff --git a/lib/elixir/test/elixir/io/ansi/docs_test.exs b/lib/elixir/test/elixir/io/ansi/docs_test.exs index 23ace94e8c1..44907477af3 100644 --- a/lib/elixir/test/elixir/io/ansi/docs_test.exs +++ b/lib/elixir/test/elixir/io/ansi/docs_test.exs @@ -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*"