GithubHelp home page GithubHelp logo

imcuttle / remark-heading-id Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 8.0 309 KB

The remark plugin for supporting custom heading id

License: MIT License

JavaScript 100.00%
remark remark-plugin markdown

remark-heading-id's Introduction

remark-heading-id

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

The remark plugin for supporting custom heading id and Default Id

Custom Heading Input

### My Great Heading {#custom-id}

Custom Heading Output

<h3 id="custom-id">My Great Heading</h3>

API

This package exports no identifiers. The default export is remarkHeaderId.

unified().use(remarkHeadingId[, options])

options

Configuration (optional).

options.defaults

Whether to add default ids based on the title text (boolean, default: false).

options.uniqueDefaults

Whether to ensure that the default ids created by options.defaults are unique (boolean, default: true). Only relevant when options.defaults = true. Example:

## heading

### introduction

### argument

## heading

### introduction

### argument

Will generate this output when options.defaults = true and options.uniqueDefaults = true:

<h2 id="heading">heading</h2>
<h3 id="indroduction">indroduction</h3>
<h3 id="argument">argument</h3>
<h2 id="heading-1">heading</h2>
<h3 id="introduction-1">introduction</h3>
<h3 id="argument-1">argument</h3>

Instead of this output, which is generated when options.defaults = true and options.uniqueDefaults = false:

<h2 id="heading">heading</h2>
<h3 id="indroduction">indroduction</h3>
<h3 id="argument">argument</h3>
<h2 id="heading">heading</h2>
<h3 id="introduction">introduction</h3>
<h3 id="argument">argument</h3>

The difference being that the last output contains duplicate ids in the generated html, which are avoided using options.uniqueDefaults = true.

Default Heading Input
### My Great Heading
Default Heading Output
<h3 id="my-great-heading">My Great Heading</h3>

Contributing

  • Fork it!
  • Create your new branch:
    git checkout -b feature-new or git checkout -b fix-which-bug
  • Start your magic work now
  • Make sure npm test passes
  • Commit your changes:
    git commit -am 'feat: some description (close #123)' or git commit -am 'fix: some description (fix #123)'
  • Push to the branch: git push
  • Submit a pull request :)

Authors

This library is written and maintained by imcuttle, [email protected].

License

MIT - imcuttle ๐ŸŸ

remark-heading-id's People

Contributors

fstafforini avatar imcuttle avatar spikeon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

remark-heading-id's Issues

Is this package still maintained?

Hi. Thanks for your work on this package! I was researching incorporating this plugin into my remark toolchain when I came across remark-custom-heading-id, which seems to fix some issues with this package and MDX compatibility, as well as updating deps to work with the latest versions of remark, though it lacks a default export. Is remark-heading-id still maintained? The example in README.md doesn't seem to work.

remark@next (13)

Hi!

remark is switching to a new parser internally (micromark, see remarkjs/remark#536 for more info).
From a quick glance at the code, it seems this plugin should be fine. However, it would be good to check that in the future (there is 13.0.0-alpha.0 published now, and one or two more will come before the release)

Pollutes by prepending `user-content-` to ids

image

It doesn't seem this lib is doing it. But I don't find how to disable it in remark.

I know it's for security measures when the content is coming from users, but my content is coming from me so I have no intention to abuse ids and have simple and pure ids, and I'd like to disable this prefix.

Any way to disable it?

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.