diff --git a/src/mistune/plugins/ruby.py b/src/mistune/plugins/ruby.py index 6cc3111..35ba79d 100644 --- a/src/mistune/plugins/ruby.py +++ b/src/mistune/plugins/ruby.py @@ -10,7 +10,7 @@ from ..markdown import Markdown -RUBY_PATTERN = r'\[(?:\w+\(\w+\))+\]' +RUBY_PATTERN = r'\[(?:\w+\([\w ]+\))+\]' _ruby_re = re.compile(RUBY_PATTERN) @@ -86,7 +86,7 @@ def _parse_ruby_link( def render_ruby(renderer: "BaseRenderer", text: str, rt: str) -> str: - return "" + text + "" + rt + "" + return "" + text + "" + rt + "" def ruby(md: "Markdown") -> None: diff --git a/tests/fixtures/ruby.txt b/tests/fixtures/ruby.txt index d89ebe2..32ff4ad 100644 --- a/tests/fixtures/ruby.txt +++ b/tests/fixtures/ruby.txt @@ -6,25 +6,25 @@ ```````````````````````````````` example [漢字(ㄏㄢˋㄗˋ)] . -

漢字ㄏㄢˋㄗˋ

+

漢字ㄏㄢˋㄗˋ

```````````````````````````````` ```````````````````````````````` example [漢(ㄏㄢˋ)字(ㄗˋ)] . -

ㄏㄢˋㄗˋ

+

ㄏㄢˋㄗˋ

```````````````````````````````` ```````````````````````````````` example [漢字(ㄏㄢˋㄗˋ)][] . -

漢字ㄏㄢˋㄗˋ[]

+

漢字ㄏㄢˋㄗˋ[]

```````````````````````````````` ```````````````````````````````` example [漢字(ㄏㄢˋㄗˋ)][link] . -

漢字ㄏㄢˋㄗˋ[link]

+

漢字ㄏㄢˋㄗˋ[link]

```````````````````````````````` ## ruby with link @@ -34,19 +34,19 @@ [漢字(ㄏㄢˋㄗˋ)][link] . -

漢字ㄏㄢˋㄗˋ

+

漢字ㄏㄢˋㄗˋ

```````````````````````````````` ```````````````````````````````` example [漢字(ㄏㄢˋㄗˋ)]() . -

漢字ㄏㄢˋㄗˋ

+

漢字ㄏㄢˋㄗˋ

```````````````````````````````` ```````````````````````````````` example [漢字(ㄏㄢˋㄗˋ)](/url) . -

漢字ㄏㄢˋㄗˋ

+

漢字ㄏㄢˋㄗˋ

```````````````````````````````` ## ruby splits @@ -54,11 +54,17 @@ ```````````````````````````````` example [漢(かん)][字(じ)] . -

かん

+

かん

```````````````````````````````` ```````````````````````````````` example [[漢(かん)][字(じ)]](https://jisho.org/search/漢字) . -

かん

+

かん

+```````````````````````````````` + +```````````````````````````````` example +[汉字(hàn zì)] +. +

汉字hàn zì

````````````````````````````````