Diego Hernandes avatar

Markdown-It Plugins: Proxy Image & Mixed HTML Fixer

hernandev

Published: 02 Jun 2018 › Updated: 02 Jun 2018

Markdown-It Plugins: Proxy Image & Mixed HTML Fixer

Repositories

New Projects

Both Mixed-HTML-Fix & Image-Proxy are plugins for Markdown-It, focusing on easy rendering Steem related content (but still good for general usage)

What is the project about?


Package: @blocker/markdown-it-mixed-html-fix

This package is a simple parsing fix to allow mixed HTML to live well with Markdown links and images.

For example:

<some-tag>foo-bar</some-tag>
![a](b.jpg)

This syntax, while used by many authors is currently rendering the links as plain text, unless this fixer-plugin is used.

Related discussions about this: https://github.com/busyorg/busy/issues/1647

Thank you fabienHive account@fabien for pointing me the problem.

Usage
const MarkdownIt = require('markdown-it')
const htmlFix = require('@blocker/markdown-it-mixed-html-fix')

const md = new MarkdownIt()
md.use(htmlFix)

Package: @blocker/markdown-it-image-proxy

Simple, but powerful plugin for parsing images with a prefix / proxy URL, just like Steemit & Busy uses https://steemitimages.com/0x0.

Usage
const MarkdownIt = require('markdown-it')
const imageProxy = require('@blocker/markdown-it-image-proxy')

const md = new MarkdownIt()
md.use(imageProxy, {
  // default proxy URL prefix.
  proxy: 'https://steemitimages.com/0x0/',
  // bypass for images on the following domains (defaults to none).
  trusted: [
    'https://i.imgur.com',
    'https://image.ibb.co'
  ]
})

This will be enough to parse all image tags with the steemitimages.com prefix.

Notice, that while prefixing image URL's, it will bypass the prefixing for the trusted origins.


Technology Stack

Minimalist Javascript, built with Rollup.

Roadmap

Those are the first installments of a series of plugins for Markdown-It, I mean to cover all Steem related parsing and sanitization as possible and bundle on a single parser package later.

How to contribute?

Github issues, comment or contact on Discord (@hernandev#5834)

GitHub Account

https://github.com/hernandev

Leave Markdown-It Plugins: Proxy Image & Mixed HTML Fixer to:

Written by

Rover, wanderer, nomad, vagabond.. Call me what you will.

Read more #utopian-io posts


Best Posts From Diego Hernandes

We have not curated any of hernandev's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Diego Hernandes