Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paperist/remark-crossref

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paperist/remark-crossref

wooorm/remark plugin for corss-references inspired by pandoc-crossref

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@paperist/remark-crossref

LICENSE NPM standard-readme compliant

wooorm/remark plugin for corss-references inspired by pandoc-crossref

Table of Contents

Install

npm i remark @paperist/remark-crossref

Usage

const unified = require('unified');
const parser = require('remark-parse');
const crossref = require('@paperist/remark-crossref');

const markdown = `
# Heading {#sec:first}

See sec.[@sec:first].
`;

const processor = unified()
  .use(parser)
  .use(crossref);
const ast = processor.parse(markdown);

processor.run(ast).then((ast) => {
  console.dir(ast, { depth: null });
});

AST

See also mdast, unist.

CrossReferenceLabel

CrossReferenceLabel extends Literal.

interface CrossReferenceLabel extends Literal {
  type: 'crossReferenceLabel';
  label: string;
  options: { [key: string]: any };
}

For example, the following markdown:

# Heading {#sec:first}

Yields:

{
  "type": "heading",
  "depth": 1,
  "children": [
    {
      "type": "text",
      "value": "Heading "
    },
    {
      "type": "crossReferenceLabel",
      "value": "{#sec:first}",
      "label": "sec:first",
      "options": {}
    }
  ]
}

CrossReference

CrossReference extends Literal.

interface CrossReference extends Literal {
  type: 'crossReference';
  identifiers: string[];
}

For example, the following markdown:

See sec.[@sec:first;@sec:second]

Yields:

{
  "type": "paragraph",
  "children": [
    {
      "type": "text",
      "value": "See sec."
    },
    {
      "type": "crossReference",
      "value": "[@sec:first;@sec:second]",
      "identifiers": ["sec:first", "sec:second"]
    }
  ]
}

Contribute

PRs accepted.

License

MIT (c) 3846masa

Keywords

FAQs

Package last updated on 21 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc