New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18next-react-markdown

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-react-markdown

Embed React elements using markdown in i18next translation strings

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

i18next-react-markdown

Embed React elements using markdown in i18next translation strings.

This wraps marksy with an HTML element and React component config import util.

Getting Started

Install and Build

npm install

Storybook

Run local storybook
npm start
Build storybook
npm run storybook:build

outputs static storybook site to docs/

Usage

This can be used in your own project and elements can be overriden with custom React components.

Locale keys must have the suffix: _md to use markdown.

Locale usage

Example locale JSON

{
  "website": "Website",
  "website-header_md": "Visit $t(website)"
}

returns "Visit Website"

i18next processor initialisation

import mdProcessor, { parser as mdParser } from 'i18next-react-markdown';

const elements = {
  h1({ id, children }: Attributes) {
    return (
      <h1 id={id}>
        {children}
      </h1>
    );
  },
}

const components = {
  Card({ children }: Attributes) {
    return (
      <div class="card">
        {children}
      </div>
    );
  },
}

const mdProcessor = createProcessor({
  elements,
  components,
  marksyOptions: {} // additional marksy input after elements and components
  markedOptions: {}
});

i18n
  .use(mdProcessor)
  .init({
    // ...
    postProcess: ['react-markdown'],
    // ...
  })

Editor usage

import Editor from 'i18next-react-markdown/Editor';

return (
  <Editor elements={elements} components={components} />
)

Markdown parser usage

import { parser as createMdParser } from 'i18next-react-markdown';


const mdParse = createMdParser(elements, components);

Keywords

FAQs

Package last updated on 07 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc