npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-intl-marked

v0.1.0

Published

Limited-structure message component for react-intl.

Downloads

10

Readme

react-intl-marked

When you need some message structure defined in the same place as the message.

Example

<FormattedMarkedMessage
        id='greeting'
        defaultMessage="Hello |{name}|!|br|How are you today?"
        values={{name: "Winston"}} />

would render as:

<span>
    Hello <span class="marked">Winston</span>!
    <br/>
    How are you today?
</span>

The content between bars is wrapped in <span class="marked"> and |br| markers are replaced by <br/>.

Values can be React elements just as with <FormattedMessage>, the resulting tree takes advantage of React's virtual DOM.

Extending

A different marker or wrapper?

class Message extends FormattedMarkedMessage {
    marker = '*';

    mark(elements, counter) {
        let key = `star-${counter}`;
        return <span key={key} className='starred'>{elements}</span>;
    }
}

Some other substitutions?

class Message extends FormattedMarkedMessage {
    substitutions = /\*(rand)\*/g;

    rand(counter) {
        let key = `rand-${counter}`;
        return <span key={key}>{Math.random()}</span>;
    }
}

Shortcut

If you happen to have react-intl-ns installed you may use a shortcut in place of <FormattedMarkedMessage>:

import {markedShortcut} from 'react-intl-marked';
const m = markedShortcut();

m`Hello |Winston|!|br|How are you today?`

The shortcut factory may be given a namespace (a string) binding generated elements to the namespace (to be used in conjunction with IntlNsProvider and IntlNamespace).

Installation and usage

npm install react react-intl react-intl-ns react-intl-marked

Bundler and transpiler

Import main.jsx from the module:

import * from 'react-intl-marked/main.jsx';

and ensure it is passed through a transpiler. For instance, with Webpack and Babel add a loader such as:

test: /\.jsx$/,
include: 'react-intl-marked',
loader: 'babel',
query: {presets: ['es2015', 'stage-0', 'react']}

Without a transpiler

Require react, react-intl, and react-intl-marked:

var React = require('react');
var ReactIntl = require('react-intl');
var ReactIntlMarked = require('react-intl-marked');

You may also require a bundle for a specific standard edition by appending /dist/main.es5.js (ES5 is the default, and the only option, unless you are reading this in the future).

Without a bundler

Add at least the following scripts to your page:

<script src="node_modules/react/dist/react.js"></script>
<script src="node_modules/react-intl/dist/react-intl.js"></script>
<script src="node_modules/react-intl-marked/dist/main.es5.js"></script>

or take a look at a minimal example.