Markdown-rubytext plugin and GRAV

plugin-markdown-rubytext is one year old and can be improved.
I don’t have the technical skills so I am kindly asking the community’s help.

This plugin transforms any {r}text{/r:prononciation-of-text} structured expression found in markdown body of a page into the following HTML syntax:
<ruby><rb>text</rb><rp>(</rp><rt>prononciation-of-text</rt><rp>)< /rp></ruby> .
This is useful for extreme oriental languages like japanese, korean or chinese.

Actually, for some reason, it fails in GRAV if there is NO SPACE BEFORE :
some-text``SPACE``{r}text{/r:prononciation_of_text}``some-other-t ext
outputs
some-text``SPACE``<ruby><rb>text</rb><rp>(</rp><rt>prononciation-o f-text</rt><rp>)</rp></ruby``some-other-text

Result is an UNDESIRED SPACE before that should not be in japanese, korean or chinese.

The preg_match function (see below the code) seems perfect so I think its probably the interaction with GRAV that needs to be improved but I don’t know exactly where to look, what to touch and how to resolve this.

Here is the php code:

$markdown->inlineRubyText = function($excerpt) {
            if (preg_match('/\{r}(\S+){\/r:(\S+)}/', $excerpt['text'], $matches))
            {
                return
                array(
                  'extent' => strlen($matches[0]),
                  'element' => array(
                    'name' => 'ruby',
                    'handler' => 'elements',
                    'text' => array(
                        array(
                            'name' => 'rb',
                            'text' => $matches[1],
                            ),
                        array(
                            'name' => 'rp',
                            'text' => '(',
                            ),
                        array(    
                            'name' => 'rt',
                            'text' => $matches[2],
                            ),
                        array(
                            'name' => 'rp',
                            'text' => ')',
                            )
                        )
                    )
                );
            }
        };

Any solution that would reach this goal is greatly appreciated.
A possibility is also to change the structure of the whole plugin and include it in the shortcode-core or ui structure.
♪ Hope this call for php contributions will be this time heard (for the glory of GRAV ☆)

In this forum, there must be some persons able to help this plugin be at the level it should be. Thanks in advance.