Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendmyers/eleventy-plugin-emphasis
An Eleventy plugin for your Markdown syntax which puts you in control of your emphasis markup.
https://github.com/bendmyers/eleventy-plugin-emphasis
eleventy eleventy-plugin markdown markdown-it
Last synced: 4 months ago
JSON representation
An Eleventy plugin for your Markdown syntax which puts you in control of your emphasis markup.
- Host: GitHub
- URL: https://github.com/bendmyers/eleventy-plugin-emphasis
- Owner: BenDMyers
- License: mit
- Created: 2021-11-27T18:34:11.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-28T18:45:24.000Z (about 3 years ago)
- Last Synced: 2024-10-14T14:40:23.173Z (4 months ago)
- Topics: eleventy, eleventy-plugin, markdown, markdown-it
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/eleventy-plugin-emphasis
- Size: 7.81 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eleventy-plugin-emphasis
> **An [Eleventy](https://11ty.dev) plugin for your Markdown syntax which puts you in control of your emphasis markup.**
## What is this plugin for?
Markdown provides several syntaxes for emphasizing your text:
* `*Single asterisks*` get converted into `` tags
* `**Double asterisks**` get converted into `` tags
* `_Single underscores_` get converted into `` tags
* `__Double underscores__` get converted into `` tagsThis syntax is redundant, and sometimes **(once in a blue moon)** [you *might* want to use `` and `` tags](https://www.w3.org/International/questions/qa-b-and-i-tags) instead of `` and ``. Alternatively, maybe you'd like to use some of this syntax for other tags such as ``!
**This plugin lets you configure which tag your Eleventy project's `markdown-it` Markdown parser uses for text surrounded by single asterisks, double asterisks, single underscores, and double underscores.**
## Setup
In your terminal, navigate into your Eleventy project and run the following:
```bash
npm install eleventy-plugin-emphasis
```Then, add this plugin to your Eleventy config file (`.eleventy.js`):
```js
const emphasisOverrides = require('eleventy-plugin-emphasis');module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(emphasisOverrides, {
// See Options API section below for full configuration options!
'_': 'i',
'__': 'b'
});// return {...};
}
```### I'm managing my own `markdown-it` instance!
If you're managing your own instance of `markdown-it` to provide other customizations to your Markdown parsing, you can supply that instance to `eleventy-plugin-emphasis` as the `md` property in your options object:
```js
const markdownIt = require('markdown-it');
const emphasisOverrides = require('eleventy-plugin-emphasis');module.exports = function (eleventyConfig) {
const markdown = markdownIt({html: true});eleventyConfig.addPlugin(emphasisOverrides, {
'md': markdown,
'_': 'i',
'__': 'b'
});eleventyConfig.setLibrary('md', markdown);
// return {...};
}
```## Options API
All options are completely optional.
| Option | Default | Type | Purpose |
|:------:|:----------:|--------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| `'md'` | | `Object` (instance of `markdown-it`) | Pass your own instance of markdown-it to configure. If not provided, the plugin will create its own instance using the [same defaults as Eleventy](https://www.11ty.dev/docs/languages/markdown/). |
| `'*'` | `'em'` | `String` (any valid HTML tag) | Tag to use when text is surrounded in a single asterisk like `*this*` |
| `'**'` | `'strong'` | `String` (any valid HTML tag) | Tag to use when text is surrounded in double asterisks like `**this**` |
| `'_'` | `'em'` | `String` (any valid HTML tag) | Tag to use when text is surrounded in a single underscore like `_this_` |
| `'__'` | `'strong'` | `String` (any valid HTML tag) | Tag to use when text is surrounded in double underscores like `__this__` |