An open API service indexing awesome lists of open source software.

https://github.com/jubilee-works/ssml-tsx

Write SSML (Speech Synthesis Markup Language) inline within JSX or TSX
https://github.com/jubilee-works/ssml-tsx

jsx ssml tsx

Last synced: 3 months ago
JSON representation

Write SSML (Speech Synthesis Markup Language) inline within JSX or TSX

Awesome Lists containing this project

README

          

# ssml-tsx
[![Version](https://img.shields.io/npm/v/ssml-tsx.svg)](https://www.npmjs.com/package/ssml-tsx)
[![CircleCI](https://circleci.com/gh/jubilee-works/ssml-tsx.svg?style=shield)](https://circleci.com/gh/jubilee-works/ssml-tsx)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#)

Write SSML (Speech Synthesis Markup Language) inline within JSX or TSX.
This module includes type definitions for SSML.

## Install

```sh
$ npm install --save ssml-tsx
```

Add `"jsx": "react"` into your `tsconfing.json` .

```diff
{
"compilerOptions": {
...,
+ "jsx": "react",
}
}
```

## Usage

For simple usage, write ssml tag with the file name as `.tsx` extension. Don't forget the JSX pragma `@jsx ssml`.

Passing it to `renderToString` renders it as a string.

```tsx
/** @jsx ssml */
import ssml, { rendetToString } from "ssml-tsx";

console.log(renderToString(

10/1

));
// => "10/1"
```

It also works with component styles. Currently only function components are supported.

```tsx
/** @jsx ssml */
import ssml, { rendetToString, FC } from "ssml-tsx";

const Foo: FC<{ name: string }> = ({ name }) => (

{name}

What would you like to do today?



);
console.log(renderToString());
```

## Supported tags

- `` (amazon:domain)
- `` (amazon:effect)
- `` (amazon:emotion)
- ``
- ``
- ``
- ``
- `

`
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``

## Using with eslint

Use [`eslint-pllugin-react`](https://github.com/yannickcr/eslint-plugin-react) to make lint work correctly.

```sh
$ npm install --save-dev eslint-pllugin-react
```

Add this lines into your `.eslintrc.js`
```diff
plugins: [
...,
+ "react"
],
rules: {
...,
+ "react/jsx-uses-react": "error",
+ "react/jsx-uses-vars": "error",
}

```