Coder Social home page Coder Social logo

dahlia / markdown-it-jsr-ref Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 103 KB

A markdown-it plugin that turns backtick-enclosed symbols into links to JSR API references

Home Page: https://jsr.io/@hongminhee/markdown-it-jsr-ref

License: MIT License

TypeScript 100.00%
jsr markdown markdown-it markdown-it-plugin

markdown-it-jsr-ref's Introduction

markdown-it-jsr-ref

JSR npm GitHub Actions

This is a markdown-it plugin that turns backtick-enclosed symbols into links to JSR API references. For example, the following Markdown snippet:

The `jsrRef()` function takes `Options` object as its argument.

will be transformed into:

The [`jsrRef()`] function takes [`Options`] object as its argument.

[`jsrRef()`]: https://jsr.io/@hongminhee/[email protected]/doc/~/jsrRef
[`Options`]: https://jsr.io/@hongminhee/[email protected]/doc/~/Options

and rendered as:

The jsrRef() function takes Options object as its argument.

Usage

Since this plugin needs to download the index data from JSR, it requires an asynchronous initialization. After once a plugin instance is created, you don't need asynchronous operations anymore:

import MarkdownIt from "markdown-it";
import { jsrRef } from "markdown-it-jsr-ref";

const md = new MarkdownIt();
md.use(await jsrRef({
  package: "@hongminhee/markdown-it-jsr-ref",
  version: "0.1.0",  // "stable" or "unstable" is also available
  cachePath: ".jsr-cache.json",  // Optional, but highly recommended
  progress: (complete, total) => { // Optional
    console.log(`Downloading JSR index: ${complete}/${total}`);
  }
}))

Syntax

The plugin recognizes backtick-enclosed symbols as JSR references.

- `ClassName`
- `InterfaceName`
- `TypeAliasName`
- `functionName()`
- `ClassName.accessorName`
- `ClassName.methodName()`
- `Interface.propertyName`
- `Interface.callSignatureName()`

For methods and properties, you can prefix them with a tilde (~) to hide the class or interface name after rendering:

- `~ClassName.accessorName`
- `~ClassName.methodName()`
- `~Interface.propertyName`
- `~Interface.callSignatureName()`

markdown-it-jsr-ref's People

Contributors

dahlia avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.