0.0.3 • Published 2 years ago

mdit-plg-double-bracket-media v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mdit-plg-double-bracket-media

NPM version

Parse ![[path/to/media]] into html in markdown-it!

Inspired by the combination usage between vite and Obsidian.

Usage

pnpm i mdit-plg-double-bracket-media -D
// use this plugin in markdown-it
import DoubleBracketMedia from 'mdit-plg-double-bracket-media'

md.use(DoubleBracketMedia, {
  /**
   * (Optional) remove the prefix in the double brackets.
   * It will parse ![[public/path/to/img.jpg|img]] into
   * <img src="/path/to/img.jpg" alt="img" ... >
   */
  removePrefix: 'public/',
  /**
   * (Optional) after removing the provided prefix,
   * param `addPrefix` will be added to the front of url.
   *
   * For example, if the params are `{ removePrefix: 'public/', addPrefix: 'src/' }`,
   * then it will parse ![[public/path/to/img.jpg|img]] into
   * <img src="/src/path/to/img.jpg" alt="img" ... >
   */
  addPrefix: ''
})

Supported media

  • pictures: jpg, jpeg, png, gif, webp and so on
  • videos (based on browser): mp4, webm
  • audio: mp3

License

MIT License © 2022 widcardw