Mahgen Renderer

approved

by Michael Francis Williams

Display mahjong images inline or in block using Mahgen.

5 stars210 downloadsUpdated 1mo agoMIT
View on GitHub

Mahgen Renderer

This is a plugin for mahgen to render in Obsidian

If you have opinions or suggestions, please open issues to let me know, or open pull requests fix it directly!

Install

(If this plugin was accepted)

  1. Open Obsidian.
  2. Go to Settings > Community Plugins > Browse.
  3. Search for mahgen.
  4. Click Install and enable the plugin.

Build

To build the plugin, use the following commands:

npm i
npm run dev

Make the folder .obsidian/plugins/obsidian-mahgen-plugin, and copy main.js, styles.css, manifest.json inside. Go to Settings > Community Plugins. Enable 'Allow installing plugins from outside the Obsidian Hub.' Enable this plugin.

Usage

usage

You can use mg 1s2s3s, or mahgen 1112345678999m_0m. It can display the hand in between.

code snippets

It can also display the river of tiles.

code snippets 2

Displaying hand, draw, and discard. code snippets 3

There is no river mode in inline, so it's unnecessary.

More details, please refer to mahgen.

Nankiru Mode

New feature:

nankiru

The code is as follows:

Q001
东一局 西家 7巡目 0020000z
6778p1122345s77z||0p
A001
东一局 西家 7巡目 0020000z
6778p1122345s77z||0p
2s

Hand Size

In style.css, you can freely change the size of hands:

:root {
    --mahgen-base-height: 2.2em;    /* base height(for block) */
    --mahgen-inline-height: 1.8em;  /* inline hand, smaller for read */
    --mahgen-row-height: 2.2em;     /* river hand, usually same with base */
}

Furigana (Optional)

This plugin can also parse furigana syntax:

{漢字|かん|じ}
{日本語|にほんご}

Rendered output uses <ruby><rt>...</rt></ruby> in reading view and Live Preview. This furigana feature is independently implemented in this plugin, inspired by obsidian-markdown-furigana.

To avoid conflicts with dedicated furigana plugins, this feature is disabled by default. Enable it in plugin settings: Enable Furigana.

See THIRD_PARTY_NOTICES.md for attribution and reuse notes.

Known issues

  1. In the styles.css file, I used !important to ensure that the elements remain in the inline-block state because I believe that under no circumstances should these Mahjong tiles be rendered in a centered position.
  2. Rendering takes some time, so sometimes you can see original inline code like mg 1s. Click anywhere it will rerender.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.