# turndown-plugin-image-with-style

> Turndown plugin to add image align and size extensions.

Latest version **1.0.9** (published 2018-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install turndown-plugin-image-with-style
pnpm add turndown-plugin-image-with-style
yarn add turndown-plugin-image-with-style
bun add turndown-plugin-image-with-style
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2018-02-24 |
| First published | 2018-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Rusty |
| Maintainers | rustyz |
| Keywords | turndown, turndown-plugin, html-to-markdown, html, markdown, image-style, image-align |

## Links

- npm: https://www.npmjs.com/package/turndown-plugin-image-with-style
- Repository: https://github.com/levous/turndown-plugin-image-with-style
- Homepage: https://github.com/levous/turndown-plugin-image-with-style#readme
- Issues: https://github.com/levous/turndown-plugin-image-with-style/issues
- npm.io page: https://npm.io/package/turndown-plugin-image-with-style

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2018-02-24
- 1.0.8 — 2018-02-24
- 1.0.7 — 2018-02-24
- 1.0.6 — 2018-02-24
- 1.0.5 — 2018-02-17
- 1.0.4 — 2018-02-16
- 1.0.3 — 2018-02-16
- 1.0.2 — 2018-02-16
- 1.0.1 — 2018-02-16

## README

# turndown-plugin-gfm

A [Turndown](https://github.com/domchristie/turndown) plugin which captures alignment attributes from the style attribute and value from height and width attributes of an img tag adds controlled attributes using the `{attr1=val attr2=another}` pattern.  The purpose is to allow alignment while still enforcing the guard rails of converting to markdown.

## Installation

npm:

```
npm install turndown-plugin-image-with-style
```

Browser:

```html
<script src="https://unpkg.com/turndown/dist/turndown.js"></script>
<script src="https://unpkg.com/turndown-plugin-image-with-style/dist/turndown-plugin-image-with-style.js"></script>
```

## Usage

```js
// For Node.js
var TurndownService = require('turndown')
var TurndownPluginImageWithStyle = require('turndown-plugin-image-with-style')

var turndownService = new TurndownService()
turndownService.use(TurndownPluginImageWithStyle)
var markdown = turndownService.turndown('<img width="400" style="float:left" src="https://http.cat/405" alt="so awesome"/>')
```

`turndown-plugin-image-with-style` looks for the size and alignment declarations applied for image alignment and size.  
Specifically, using [Quill Image Resize Module](https://github.com/kensnyder/quill-image-resize-module) with [Quill Editor](https://quilljs.com), the editor consistently inserts specific style, height and width attributes that can be matched and handled.  

`turndown-plugin-image-with-style` will convert these to:
- style="float:left; margin:0px 1em 1em 0px;" OR style="float:right; margin:0px 0px 1em 1em;" OR display:block; margin:auto;"
- width=[value]
- height=[value]

It's then up to you to process these attributes when converting back to html.  
A handy module is: [markdown-it-attrs](https://github.com/arve0/markdown-it-attrs)
with [markdown-it](https://github.com/markdown-it/markdown-it)

example:

```js
var imageWithStyle = require('turndown-plugin-image-with-style')
var turndownService = new TurndownService()
turndownService.use(imageWithStyle)
```

## License

turndown-plugin-image-with-style is released under the MIT license.  All original [Turndown](https://github.com/domchristie/turndown) copyright belongs to Dom Christie, also released under the MIT license.

---
_Source: https://npm.io/package/turndown-plugin-image-with-style · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
