Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Slidev transformer integrating BudouX for better text wrapping!

License

Notifications You must be signed in to change notification settings

ryoppippi/slidev-transformer-budoux

Repository files navigation

slidev-transformer-budoux

JSR JSR

A Slidev transformer that integrates BudouX for improved text wrapping in Japanese, Simplified Chinese, Traditional Chinese, and Thai languages.

Caution

Maybe you don't need this transformer. Just add the following snippet to index.html

<head>
    <script src="https://unpkg.com/budoux/bundle/budoux-ja.min.js"></script>
</head>

More info at BudouX

Features

  • Supports automatic line breaking for:
    • Japanese (ja)
    • Simplified Chinese (cs)
    • Traditional Chinese (ct)
    • Thai (th)
  • Easy integration with Slidev
  • Customizable default language

Installation

npx jsr add @ryoppippi/slidev-transformer-budoux

Setup

Add the transformer to your Slidev setup file:

// setup/transformers.ts
import { budouxCodeblock } from '@ryoppippi/slidev-transformer-budoux';
import { defineTransformersSetup } from '@slidev/types';

export default defineTransformersSetup(() => {
	return {
		pre: [],
		preCodeblock: [budouxCodeblock('ja')], // Set the default language (optional)
		postCodeblock: [],
		post: [],
	};
});

Usage

In your Slidev markdown files, use the <budoux> tag or language-specific tags:

<budoux>こんにちは、世界!</budoux>
<budoux-ja>こんにちは、世界!</budoux-ja>
<budoux-cs>你好世界!</budoux-cs>
<budoux-ct>你好世界!</budoux-ct>
<budoux-th>สวัสดีโลก!</budoux-th>

See actual processing results from slides.md in GH pages.

API

budouxCodeblock(defaultLanguage?: Language)

Creates a transformer function for Slidev.

  • defaultLanguage: Optional. Sets the default language for <budoux> tags. Defaults to 'ja'.

Supported Languages

  • Japanese (ja)
  • Simplified Chinese (cs)
  • Traditional Chinese (ct)
  • Thai (th)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

This project uses BudouX for text segmentation.