Custom version of Quartz for my Japanese Grammar (JPG) project
Go to file
Théo Marchal 60b63687e8 Squashed 'custom/convert-furigana/' changes from f21e49b..40c6789
40c6789 Fixed kanji parsing by adding 々

git-subtree-dir: custom/convert-furigana
git-subtree-split: 40c67897788021b364f2e768944b1966df069033
2024-05-21 15:46:18 +02:00
examples Squashed 'custom/convert-furigana/' content from commit f21e49b 2024-04-06 18:30:42 +02:00
program Squashed 'custom/convert-furigana/' changes from f21e49b..40c6789 2024-05-21 15:46:18 +02:00
LICENSE Squashed 'custom/convert-furigana/' content from commit f21e49b 2024-04-06 18:30:42 +02:00
README.md Squashed 'custom/convert-furigana/' content from commit f21e49b 2024-04-06 18:30:42 +02:00

convert-furigana

What is it?

There are a few extensions that add furigana support to Markdown. I use Obsidian, and therefore its furigana extension: obsidian-markdown-furigana. It works well, but by nature is limited by being used within Obsidian.

For that purpose, this python script converts this specific syntax to common, all-platforms HTML ruby tags.

Process

This specific extension syntax is as following:

{漢字|かんじ}
{漢字|かん|じ}

When processed by this script, the result is:

<ruby>漢字<rt>かんじ</rt></ruby>
<ruby>漢<rt>かん</rt>字<rt>じ</rt></ruby>

Which leads visually from, by default markdown standards:

{漢字|かんじ}

{漢字|かん|じ}

to common HTML ruby syntax:

漢字かんじ

かん

Limitations

This has been made for my personal use, which is only kanjis with kanas as furigana. The regexp used do not recognize other inputs. But you can modify them easily for your use if needed.

Usage

Usage: python3 convert-furigana.py [root folder]

Note: Please be careful, this software applies modifications recursively!