Installation of [markdown extra extension package to wrap the <ruby> tag]

When working with Regex I suggest trying it here: https://regex101.com/

This way you can put your test string in and tweak the regex until it matches as you want it, then paste the resulting code back into PHP. BTW you don’t need the first and last / characters… those are for PHP only.

Thank you but I can’t get how this to work!

Whatever I try, it’s: ‘no match’…
I can’t find any clue… I am not even sure of what to put and where.

\wis given as matching any word character [a-zA-Z0-9_]: does regex \w is able to deal with japanese characters?

Once I made something on regex (be witout being able to have something matching), I test it my php document and I have an error…

I am in a maze here… Please help

taking off the first and last / makes an error too …

finally, there was something to match with regex:

^{r}([\S]+){\/r:([\S]+)}

but testing it in grav, is leading to an error with the handler of Parsedown and ParsedownExtra:

Capture6

it seems that this:

'text' => array (
                            'element' => array(
                                'name' => 'rb',
                                'text' => $matches[1]),
                            'element' => array(    
                                'name' => 'rt',
                                'text' => $matches[2]),
                            ),

IS NOT valid.
[probably because it should be a string…]

How can it be written differently to get to output:

—html
日本語にほんご


?

getting close to the point...

Progress:
code

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

gave the ouptput:
—html
にほんご

any idea?

Probably not able to deal with 2 statements ‘element’ so taking only the last one… any idea?

please help

Hi @tidivoit I’m not used to Markdown parsing, but it seems you are right: only one element is valid and your code is overwriting the first element entry, too. I’ve reverse engineered how Parsedown (the Markdown Parser) works. The following code (inside the if condition) should return

<ruby><rb>日本語</rb><rt>にほんご</rt></ruby>

Code:

return array(
  'extent' => strlen($matches[0]),
  'element' => array(
    'name' => 'ruby',
    'handler' => 'elements',
    'text' => array(
      array(
        'name' => 'rb',
        'text' => $matches[1],
      ),
      array(     
        'name' => 'rt',
        'text' => $matches[2],
      )
    )
  )
);

it worked beautifully!!!
☆ Thank you very very very much!!!

So, this plugin is ready for release now! GREAT!!!
it’s going to be easier to publish in eastern languages with this ♪ … Good for Grav!!!

Next step is too release it properly following manual on ‘learn.getgrav.org’…

@Sommerregen

THANNNNKS AGAINNNNN!!!

Awesome work guys!