Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayecue/text-mesh-transformer
Transformer for TextMesh Pro Rich Text tags.
https://github.com/ayecue/text-mesh-transformer
Last synced: 15 days ago
JSON representation
Transformer for TextMesh Pro Rich Text tags.
- Host: GitHub
- URL: https://github.com/ayecue/text-mesh-transformer
- Owner: ayecue
- License: mit
- Created: 2022-09-28T00:43:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-25T20:59:51.000Z (about 1 year ago)
- Last Synced: 2024-10-06T09:17:52.338Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 2.11 MB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# text-mesh-transformer
[![text-mesh-transformer](https://circleci.com/gh/ayecue/text-mesh-transformer.svg?style=svg)](https://circleci.com/gh/ayecue/text-mesh-transformer)
# Install
```
npm i text-mesh-transformer
```# Description
Transformer for [TextMesh Pro Rich Text](http://digitalnativestudios.com/textmeshpro/docs/rich-text) tags.
# Usage
```js
const ansiStyles = await import('ansi-styles');
const transform = require('./dist/index.js').default;
const Tag = require('./dist/index.js').Tag;const str = transform(`
foo test moo bar
`, (openTag, content) => {
switch (openTag.tag) {
case Tag.Color: {
if (openTag.value in ansiStyles) {
return `${ansiStyles[openTag.value].open}${content}${ansiStyles[openTag.value].close}`;
}
break;
}
case Tag.Underline:
return `${ansiStyles.modifier.underline.open}${content}${ansiStyles.modifier.underline.close}`;
case Tag.Italic:
return `${ansiStyles.modifier.italic.open}${content}${ansiStyles.modifier.italic.close}`;
case Tag.Bold:
return `${ansiStyles.modifier.bold.open}${content}${ansiStyles.modifier.bold.close}`;
}return content;
});
console.log(str); //returns styled console.log string
```