Coder Social home page Coder Social logo

markdown-it-toc-and-anchor's Introduction

markdown-it-toc-and-anchor

circleci AppVeyor Build Status Version Coverage Status Dependency Status Greenkeeper badge

markdown-it plugin to add toc and anchor links in headings

Installation

$ yarn add markdown-it-toc-and-anchor

Usage

ES6

import markdownIt from "markdown-it"
import markdownItTocAndAnchor from "markdown-it-toc-and-anchor"

markdownIt({
    html: true,
    linkify: true,
    typographer: true,
  })
    .use(markdownItTocAndAnchor, {
      // ...options
    })
    .render(md)

ES5 / CommonJS

var markdownIt = require('markdown-it'),
    markdownItTocAndAnchor = require('markdown-it-toc-and-anchor').default;

markdownIt({
    html: true,
    linkify: true,
    typographer: true,
  })
    .use(markdownItTocAndAnchor, {
      // ...options
    })
    .render(md)

ℹ️ Note that the 'default' property has to be used when requiring this plugin, this is due to the use of Babel 6 now making ES6 compliant exports (Misunderstanding ES6 Modules, Upgrading Babel, Tears, and a Solution )

Options

toc

(default: true)

Allows you to enable/disable the toc transformation of @[toc]

tocClassName

(default: "markdownIt-TOC")

Option to customize html class of the <ul> wrapping the toc. If no class is wanted set to null.

tocFirstLevel

(default: 1)

Allows you to skip some heading level. Example: use 2 if you want to skip <h1> from the TOC.

tocLastLevel

(default: 6)

Allows you to skip some heading level. Example: use 5 if you want to skip <h6> from the TOC.

tocCallback

(default: null)

Allows you to get toc contents externally by executing a callback function returning toc elements, in addition / instead of using @[toc] tag in content. Example :

  markdownIt({
    html: true,
    linkify: true,
    typographer: true,
  })
    .use(markdownItTocAndAnchor, {
      tocCallback: function(tocMarkdown, tocArray, tocHtml) {
        console.log(tocHtml)
      }
    })
    .render(md)

To allow callback to be more flexible, this option is also available in global markdown-it options, and in render environment. Example :

Callback in global markdown-it options
  var mdIt = markdownIt({
    html: true,
    linkify: true,
    typographer: true,
  })
    .use(markdownItTocAndAnchor)

  ....

  mdIt.set({
    tocCallback: function(tocMarkdown, tocArray, tocHtml) {
      console.log(tocHtml)
    }
  })
    .render(md)
Callback in render environment
  var mdIt = markdownIt({
    html: true,
    linkify: true,
    typographer: true,
  })
    .use(markdownItTocAndAnchor)

  ....

  mdIt
    .render(md, {
      tocCallback: function(tocMarkdown, tocArray, tocHtml) {
        console.log(tocHtml)
      }
    })

anchorLink

(default: true)

Allows you to enable/disable the anchor link in the headings

anchorLinkSymbol

(default: "#")

Allows you to customize the anchor link symbol

anchorLinkSpace

(default: true)

Allows you to enable/disable inserting a space between the anchor link and heading.

anchorLinkSymbolClassName

(default: null)

Allows you to customize the anchor link symbol class name. If not null, symbol will be rendered as <span class="anchorLinkSymbolClassName">anchorLinkSymbol</span>.

anchorLinkBefore

(default: true)

Allows you to prepend/append the anchor link in the headings

anchorLinkPrefix

(default: undefined)

Allows you to add a prefix to the generated header ids, e.g. section-.

anchorClassName

(default: "markdownIt-Anchor")

Allows you to customize the anchor link class. If no class is wanted set to null.

wrapHeadingTextInAnchor

(default: false)

Makes the entire heading into the anchor link (takes precedence over anchorLinkSymbol and anchorLinkBefore)

resetIds

(default: true)

Allows you to reset (or not) ids incrementation. Use it if you will have multiple documents on the same page.

slugify

(default: uses the uslug package)

Allows you to customize the slug function that create ids from string.

Ex:

   // ...
   slugify : string => `/some/prefix/${string.replace(/(\/| |')/g, "_")}`
   // ...

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ npm test).

markdown-it-toc-and-anchor's People

Contributors

asmsuechan avatar cesalberca avatar greenkeeper[bot] avatar jsepia avatar medfreeman avatar moox avatar ruanyf avatar tylerlong avatar watagashi 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  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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

markdown-it-toc-and-anchor's Issues

should not require markdown-it

Plugins should not require markdown-it, to reduce bloat. A worse case scenario:

node_modules/markdown-it (5.0.0)
node_modules/plugin1/node_modules/markdown-it (4.0.0)
node_modules/plugin2/node_modules/markdown-it (4.4.0)

We now have three copies of markdown-it.

Token can be accessed through state.Token in rules. state is passed as the first argument.

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 5.13.0 to 5.14.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: build-job: Your tests failed on CircleCI (Details).
  • continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).

Release Notes for v5.14.0
  • 85a04b3 Fix: adds conditional for separateRequires in one-var (fixes #10179) (#10980) (Scott Stern)
  • 0c02932 Upgrade: [email protected] (#11401) (Ilya Volodin)
  • 104ae88 Docs: Update governance doc with reviewers status (#11399) (Nicholas C. Zakas)
  • ab8ac6a Fix: Support boundary spread elements in sort-keys (#11158) (Jakub Rożek)
  • a23d197 New: add allowSingleLineBlocks opt. to padded-blocks rule (fixes #7145) (#11243) (richie3366)
  • e25e7aa Fix: comma-spacing ignore comma before closing paren (fixes #11295) (#11374) (Pig Fang)
  • a1f7c44 Docs: fix space-before-blocks correct code for "classes": "never" (#11391) (PoziWorld)
  • 14f58a2 Docs: fix grammar in object-curly-spacing docs (#11389) (PoziWorld)
  • d3e9a27 Docs: fix grammar in “those who says” (#11390) (PoziWorld)
  • ea8e804 Docs: Add note about support for object spread (fixes #11136) (#11395) (Steven Thomas)
  • 95aa3fd Docs: Update README team and sponsors (ESLint Jenkins)
  • 51c4972 Update: Behavior of --init (fixes #11105) (#11332) (Nicholas C. Zakas)
  • ad7a380 Docs: Update README team and sponsors (ESLint Jenkins)
  • 550de1e Update: use default keyword in JSON schema (fixes #9929) (#11288) (Pig Fang)
  • 983c520 Update: Use 'readonly' and 'writable' for globals (fixes #11359) (#11384) (Nicholas C. Zakas)
  • f1d3a7e Upgrade: some deps (fixes #11372) (#11373) (薛定谔的猫)
  • 3e0c417 Docs: Fix grammar in “there’s nothing prevent you” (#11385) (PoziWorld)
  • de988bc Docs: Fix grammar: Spacing improve -> Spacing improves (#11386) (PoziWorld)
  • 1309dfd Revert "Build: fix test failure on Node 11 (#11100)" (#11375) (薛定谔的猫)
  • 1e56897 Docs: “the function actually use”: use -> uses (#11380) (PoziWorld)
  • 5a71bc9 Docs: Update README team and sponsors (ESLint Jenkins)
  • 82a58ce Docs: Update README team and sponsors (ESLint Jenkins)
  • 546d355 Docs: Update README with latest sponsors/team data (#11378) (Nicholas C. Zakas)
  • c0df9fe Docs: ... is not an operator (#11232) (Felix Kling)
  • 7ecfdef Docs: update typescript parser (refs #11368) (#11369) (薛定谔的猫)
  • 3c90dd7 Update: remove prefer-spread autofix (fixes #11330) (#11365) (薛定谔的猫)
  • 5eb3121 Update: add fixer for prefer-destructuring (fixes #11151) (#11301) (golopot)
  • 173eb38 Docs: Clarify ecmaVersion doesn't imply globals (refs #9812) (#11364) (Keith Maxwell)
  • 84ce72f Fix: Remove extraneous linefeeds in one-var fixer (fixes #10741) (#10955) (st-sloth)
  • 389362a Docs: clarify motivation for no-prototype-builtins (#11356) (Teddy Katz)
  • 533d240 Update: no-shadow-restricted-names lets unassigned vars shadow undefined (#11341) (Teddy Katz)
  • d0e823a Update: Make --init run js config files through linter (fixes #9947) (#11337) (Brian Kurek)
  • 92fc2f4 Fix: CircularJSON dependency warning (fixes #11052) (#11314) (Terry)
  • 4dd19a3 Docs: mention 'prefer-spread' in docs of 'no-useless-call' (#11348) (Klaus Meinhardt)
  • 4fd83d5 Docs: fix a misleading example in one-var (#11350) (薛定谔的猫)
  • 9441ce7 Chore: update incorrect tests to fix build failing (#11354) (薛定谔的猫)
Commits

The new version differs by 38 commits.

  • af9688b 5.14.0
  • 0ce3ac7 Build: changelog update for 5.14.0
  • 85a04b3 Fix: adds conditional for separateRequires in one-var (fixes #10179) (#10980)
  • 0c02932 Upgrade: [email protected] (#11401)
  • 104ae88 Docs: Update governance doc with reviewers status (#11399)
  • ab8ac6a Fix: Support boundary spread elements in sort-keys (#11158)
  • a23d197 New: add allowSingleLineBlocks opt. to padded-blocks rule (fixes #7145) (#11243)
  • e25e7aa Fix: comma-spacing ignore comma before closing paren (fixes #11295) (#11374)
  • a1f7c44 Docs: fix space-before-blocks correct code for "classes": "never" (#11391)
  • 14f58a2 Docs: fix grammar in object-curly-spacing docs (#11389)
  • d3e9a27 Docs: fix grammar in “those who says” (#11390)
  • ea8e804 Docs: Add note about support for object spread (fixes #11136) (#11395)
  • 95aa3fd Docs: Update README team and sponsors
  • 51c4972 Update: Behavior of --init (fixes #11105) (#11332)
  • ad7a380 Docs: Update README team and sponsors

There are 38 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Since V4.0.0 this breaks other modules

It is a bit mysterious, since I updated this module some other markdown-it modules wont work like:

  • markdown-it-abbr
  • markdown-it-footnote

In both I got the same error: state.env is undefined and so this modules can't access its sub-properties.
I didn't change anything in these and if I downgrade your module back to V3.1.0 everything is working again.

Did you accidentally delete the state.env within markdown-it?

Hope you can fix this to get your new version working properly, again.

Token class methods are undefined

Before I add markdown-it-toc-and-anchor, there are five class methods available for the tokens:

screen shot 2016-10-12 at 10 43 57 am

After adding markdown-it-toc-and-anchor, they are undefined:

screen shot 2016-10-12 at 10 44 18 am

This is as far as I’ve gotten in debugging, let me know if there’s more helpful information I can provide. I would love to use these class methods if possible.

Automatic numbering

Hi guys - well done plugin, works great for my use case.

Quick question:

Would love to add an option to automatically number headings like this:

My TOC

  1. Section 1
    1.1 Subsection 1 of 1
    1.2 Subsection 2 of 1
  2. Section 2

1 Section 1

Section 1 contents here

1.2 Subsection 1 of 1

Contents of subsection 1 of 1 here

...

Any hints on how you would go about implementing this? Happy to give it a shot but maybe you can point me to some potential pitfalls or shortcuts before I dive in. Maybe I could add a callback function as an option to generate the number prefix based on level and counter ?

An in-range update of babel7 is breaking the build 🚨

There have been updates to the babel7 monorepo:

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.

babel7 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: build-job: Your tests failed on CircleCI (Details).
  • coverage/coveralls: First build on greenkeeper/monorepo.babel7-20190205004352 at 100.0% (Details).
  • continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

cannot read property 'breaks' of undefined

I tried to use this library as plugin in webpack project, but it returns error cannot read property 'breaks' of undefined. I did have the option for breaks in markdown-it.

Reduce the bundle size

Hi, after use this plugin, I noticed the bundle size increased over 87 KB even though gzipped.
Do you have any ideas about it?

p.s.
uslug: 51.56 KB, unorm: 35.96 KB.

How to build the code

Hi, It seems the code is not standard javascript. It looks like coffeescript but it's not. Could you please kindly tell me which js dialect it is? I need to know this in order to build and generate dist/index.js.

Thank you in advance.

An in-range update of ava is breaking the build 🚨

The devDependency ava was updated from 1.0.1 to 1.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ava is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: build-job: Your tests failed on CircleCI (Details).
  • continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).
  • coverage/coveralls: First build on greenkeeper/ava-1.1.0 at 100.0% (Details).

Release Notes for 1.1.0

1.1.0

New features

AVA now exports a meta object. Currently, you can retrieve the path of the test file being run:

import test from 'ava';

console.log('Test currently being run: ', test.meta.file);

import {meta} from 'ava';

console.log('Test currently being run: ', meta.file);

This is useful in helpers that need to know the test file. bccd297

Bug fixes and other improvements

  • t.log() now works in hooks d187712

  • Error output for improper usage of t.throws() once again links to the correct documentation dc552bc

  • We've added a section on webpack aliases to the Babel recipe c3bcbf2

  • We've updated the Vue recipe for Babel 7, and added a section on webpack aliases c3bcbf2

All changes 📚

v1.0.1...v1.1.0

Thanks 💌

💖 Huge thanks to @fitztrev, @forresst, @astrob0t, @pearofducks, @coreyfarrell and @dflupu for helping us with this release. We couldn’t have done it without you!

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

Commits

The new version differs by 9 commits.

  • a28094a 1.1.0
  • 7262a78 Bump dependencies
  • d187712 Fix t.log() in hooks
  • bccd297 Expose test file path within worker process
  • c3bcbf2 Improve Babel and Vue recipes
  • dc552bc Update link to t.throws() assertion in AVA output
  • f4b2d19 Fix links to French translation of docs (#2005)
  • 2e72fe7 Fix npm install command in readme (#2001)
  • 7b6e578 Use newer ES syntax where possible

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

resetIds doesn't work

How to reproduce:

var markdownIt = require("markdown-it");
var markdownItTocAndAnchor = require("markdown-it-toc-and-anchor").default;

var mdi = markdownIt({ html: true, linkify: true, typography: true,}).use(markdownItTocAndAnchor, { resetIds: true });
mdi.render('# heading');
mdi.render('# heading');
mdi.render('# heading');
> var markdownIt = require("markdown-it");
undefined
> var markdownItTocAndAnchor = require("markdown-it-toc-and-anchor").default;
undefined
> 
> var mdi = markdownIt({ html: true, linkify: true, typography: true,}).use(markdownItTocAndAnchor, { resetIds: true });
undefined
> mdi.render('# heading')
'<h1 id="heading"><a class="markdownIt-Anchor" href="#heading">#</a> heading</h1>\n'
> mdi.render('# heading')
'<h1 id="heading-2"><a class="markdownIt-Anchor" href="#heading-2">#</a> heading</h1>\n'
> mdi.render('# heading')
'<h1 id="heading-3"><a class="markdownIt-Anchor" href="#heading-3">#</a> heading</h1>\n'

link inside heading not rendered correctly.

Example:

# [test](http://google.com)

## Table of Contents

@[toc]

Rendered:

screen shot 2016-01-09 at 10 44 25 pm

We can see that the raw markdown it shown in TOC.

Similarly, # **text**, # *text*, # ~~text~~ are not rendered correctly in TOC.

And emojis has this problem too: # :dog:

I think the key to the problem is: After this plugin generate TOC, the content of TOC should still go through processing of other plugins such as emoji.

I tried to solve it, but hasn't made much progress yet. It is appreciate if some one could give me some hints. I would be more than happy to get this done and submit a PR.

Thank you in advance.

Tapping into renderAnchorLink

Hi,

I want to add some attributes to the anchor link (the <a> tag) apart from the default class and href attributes. Is there a way to do this without modifying source code?

Thanks,
Zhijun

Plugin crashes when heading has no content

When a heading has no content, the plugin crashes because it is trying to access properties of the child nodes of the heading, which don't exist.

Here is the output from a node session illustrating the issue.

$ node
> const markdownIt = require('markdown-it')
undefined
> const markdownItTocAndAnchor = require('markdown-it-toc-and-anchor').default
undefined
> markdownIt().use(markdownItTocAndAnchor).render('## Real heading\n\n##\n\nEmpty heading above')
TypeError: Cannot read property 'type' of undefined
    at Array.<anonymous> (/node_modules/markdown-it-toc-and-anchor/dist/index.js:55:53)
    at Core.process (/node_modules/markdown-it/lib/parser_core.js:51:13)
    at MarkdownIt.parse (/node_modules/markdown-it/lib/index.js:523:13)
    at MarkdownIt.render (/node_modules/markdown-it/lib/index.js:543:36)

The versions used are:

  • Node.js 10.2.1
  • markdown-it 8.4.1
  • markdown-it-toc-and-anchor 4.1.2

Bug in v2.1.0

If I use the new version 2.1.0 I get the error:

TypeError: Object #<Object> has no method 'apply'
at MarkdownIt.use (/home/alex/github/node-report/node_modules/markdown-it/lib/index.js:497:10)

I had a look at what the plugin exports (an object):

{ default: [Function] }

Now I switched back to version 2.0.0 and it works again. The plugin exports
a function now:

function (md, options) {
  options = _extends({
    toc: true,
    tocClassName: "markdownIt-TOC",
    tocFirstLevel: 1,
    anchorLink: true,
    anchorLinkSymbol: "#",
    anchorLinkBefore: true,
    anchorClassName: "markdownIt-Anchor",
    resetIds: true,
    indentation: "  " }, options);
...

Maybe there is a small problem here which you hopefully can fix.

[feature request] anchor link like GitHub

Example:

<a id="user-content-indentation" class="anchor" href="#indentation" aria-hidden="true">
    <span class="octicon octicon-link"></span>
</a>

In order to support above, need to set anchorLinkSymbol to <span class="octicon octicon-link"></span>. But unfortunately it is escaped.

I will take a look and see if I can provide a PR.

Should support unicode heading

When heading contains only unicode characters the anchor link is empty.

Example: # 新年快乐

I have fixed this issue and will submit PR soon.

TypeError: Cannot read property 'breaks' of undefined

var markdownIt = require('markdown-it'),
    markdownItTocAndAnchor = require('markdown-it-toc-and-anchor').default;

markdownIt({
    html: true,
    linkify: true,
    typography: true,
  })
    .use(markdownItTocAndAnchor, {
      // ...options
    })
    .render("## Hello World! Hexo!\n\n从wordpress转Hexo啦!\n\n<!--more-->\n\n### Hello World! Hexo!\n\n## Hello World! Hexo!\n\nHexo真的比wordpress,geek多了,零成本博客不是梦!\n\n## Hello World! Hexo!\n\n现在还在配置主题和Hexo,下面列出建站过程中利用到的工具和开源项目。顺便熟悉markdown语法。\n\n#### Hello World! Hexo!\n\n* [Hexo](https://hexo.io) 基于node的博客框架\n* [hexo-theme-material](https://github.com/viosey/hexo-theme-material) Material 原质 -- 酷炫的md风格主题\n* [Coding](https://coding.net) 国内免费的pages服务,本站由Coding托管\n* [Vscode](https://code.visualstudio.com/) 我使用vscode写markdown\n\n头像自动同步qq头像,调用的是这个接口\n\n[http://q1.qlogo.cn/headimg_dl?bs=QQ号&dst_uin=QQ号&spec=100&url_enc=0&referer=bu_interface&term_type=PC](http://q1.qlogo.cn/headimg_dl?bs=1106996185&dst_uin=1106996185&spec=100&url_enc=0&referer=bu_interface&term_type=PC)")

image

Tests not working correctly on Windows

Depending on my location i develop on different platforms.
On windows 7 yesterday, i noticed that eslint scans the whole folder structure, not only src folder.
And globs seem to be not supported directly on npm scripts on windows, causing ava not to find any test file to process.
I'll submit a pull request in a few minutes, i confirm it also works on macOSX with the new syntax, not tested on linux, but should work without problems.

TypeError: Cannot read property 'type' of undefined

Hi, I'm trying to use this plugin in X1011/X1011.github.io@cb87cf4, but I get this error:

toc-and-anchor $ pug --obj pug-config.js experience.pug 

/home/dan/drive/programming/X1011.github.io/node_modules/pug-filters/lib/handle-filters.js:54
        throw ex;
        ^

TypeError: Cannot read property 'type' of undefined
    at Array.<anonymous> (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it-toc-and-anchor/dist/index.js:102:36)
    at ParserInline.tokenize (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it/lib/parser_inline.js:135:22)
    at ParserInline.parse (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it/lib/parser_inline.js:163:8)
    at Array.inline (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it/lib/rules_core/inline.js:10:23)
    at Core.process (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it/lib/parser_core.js:51:13)
    at MarkdownIt.parse (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it/lib/index.js:519:13)
    at MarkdownIt.render (/home/dan/drive/programming/X1011.github.io/node_modules/markdown-it/lib/index.js:539:36)
    at filterWithFallback (/home/dan/drive/programming/X1011.github.io/node_modules/pug-filters/lib/handle-filters.js:46:38)
    at walk.includeDependencies (/home/dan/drive/programming/X1011.github.io/node_modules/pug-filters/lib/handle-filters.js:26:18)
    at walkAST (/home/dan/drive/programming/X1011.github.io/node_modules/pug-walk/index.js:13:26)

The offending line corresponds to this one in your source file, and it seems state.tokens.slice(-1) is empty when this occurs.

The same error occurred when i tried the other 2 toc plugins, markdown-it-toc and markdown-it-table-of-contents.

update npm release version please.

i had meet this problem.
TypeError: Cannot read property 'type' of undefined
and i found the problem is from dist/index.js at 55 line and src/index.js at 174
if (heading.children && heading.children[0].type === "link_open") {
the problem is heading.children's length is 0 and try to get the element from heading.children.
and i found the problem had been solved in gist src/index.js at Line 173
now the latest is v4.1.2, update npm release version please.

vue.esm.js?af24:1741 TypeError: link.attrIndex is not a function

Looks link.attrIndex could be undefined:

vue.esm.js?af24:1741 TypeError: link.attrIndex is not a function
    at findFirstMatchingConfig (index.js?47a1:7)
    at Object.md.renderer.rules.link_open (index.js?47a1:54)
    at Renderer.renderInline (renderer.js?1643:271)
    at Renderer.render (renderer.js?1643:324)
    at MarkdownIt.render (index.js?cf6b:543)
    at VueComponent.markdown2html (index.js?58b7:19)

Relevant code:

function findFirstMatchingConfig (link, configs) {
  var i, config
  var href = link.attrs[link.attrIndex('href')][1]

License problem: uslug -> unorm -> GPL 2

Hello,
I was asked to run a license assessment for my codebase and I found out that one of the dependencies you are actually using (uslug) has another dependency (unorm) that is double licensed which is causing a license pollution (in particular GPL 2, that requires code disclosure).

I was wondering if you're willing to consider to migrate from uslug (which is actually 4 years old) to something like slug.

In any case, thanks for your time.

Keep the good job ;)

PS: I opened a pull request with the new dependency

Compatibility with target=_blank rules/plugins

I'm trying to get a target=_blank markdown plugin to work along with this plugin. I noticed some issues:

  1. The anchor tokens generated by this is are not Token instances. This means I have to do a try {} catch {} around the code that is based off of https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer

  2. When I get type=link_open Tokens for the TOC generated parts they don't have any identifiers that they were generated by this plugin. It would be good to also apply the className to the links themselves in addition to the ul divs.

An in-range update of nyc is breaking the build 🚨

The devDependency nyc was updated from 13.1.0 to 13.2.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

nyc is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: build-job: Your tests failed on CircleCI (Details).
  • coverage/coveralls: First build on greenkeeper/nyc-13.2.0 at 100.0% (Details).
  • continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).

Commits

The new version differs by 17 commits.

  • 29e6f5e chore(release): 13.2.0
  • e95856c chore: Update dependencies. (#978)
  • 921d386 fix: Create directory for merge destination. (#979)
  • df2730d feat: Option Plugins (#948)
  • 35cd49a feat: document the fact that cacheDir is configurable (#968)
  • ff834aa feat: avoid hardcoded HOME for spawn-wrap working dir (#957)
  • 35710b1 build: move windows tests to travis (#961)
  • 93cb5c1 tests: coverage for temp-dir changes (#964)
  • d566efe test: stop using LAZY_LOAD_COUNT (#960)
  • f23d474 chore: update stale bot config with feedback (#958)
  • 62d7fb8 chore: slight tweak to position of test
  • 28b6d09 fix: missing command temp-directory (#928)
  • 40afc5f fix: nyc processing files not covered by include when all is enabled. (#914)
  • ba22a26 docs(readme): Update to reflect .nycrc.json support (#934)
  • 2dbb82d chore: enable probot-stale

There are 17 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Paragraph wraps TOC

When I try to place TOC with placeholder @[toc], it produce paragraph tags around.

        md.use(
            markdownItTocAndAnchor,
            {
                toc: true,
                tocFirstLevel: 2,
                tocLastLevel: 3,
                anchorLink: false
            }
        );
# Header 1

@[toc]

## Subheader 1

Test text
<h1 id="header-1">Header 1</h1>
<p><ul class="markdownIt-TOC">
<li><a href="#subheader-1">Subheader 1</a></li>
</ul>
</p>
<h2 id="subheader-1">Subheader 1</h2>
<p>Test text</p>

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.16.0 to 2.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: build-job: Your tests failed on CircleCI (Details).
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Commits

The new version differs by 61 commits.

  • 0499050 bump to v2.17.0
  • f479635 [webpack] v0.11.1
  • 8a4226d Merge pull request #1320 from bradzacher/export-ts-namespaces
  • 988e12b fix(export): Support typescript namespaces
  • 70c3679 [docs] make rule names consistent
  • 6ab25ea [Tests] skip a TS test in eslint < 4
  • 405900e [Tests] fix tests from #1319
  • 2098797 [fix] export: false positives for typescript type + value export
  • 70a59fe [fix] Fix overwriting of dynamic import() CallExpression
  • e4850df [ExportMap] fix condition for checking if block comment
  • 918567d [fix] namespace: add check for null ExportMap
  • 2d21c4c Merge pull request #1297 from echenley/ech/fix-isBuiltIn-local-aliases
  • 0ff1c83 [dev deps] lock typescript to ~, since it doesn’t follow semver
  • 40bf40a [*] [deps] update resolve
  • 28dd614 Merge pull request #1304 from bradennapier/feature/typescript-export-type

There are 61 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Doesn't work

For some reason, browserified version doesn't work for me. It gives me an error:

Uncaught TypeError: plugin.apply is not a function
    at MarkdownIt.use (markdown-it.js:1083)
    at init.js:20 <-- this is my init file

Line 1083 from makdown-it.js:

MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
  var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
  plugin.apply(plugin, args); // <----------- Line 1083
  return this;
};

Line 20 from init.js:

var markdownConverter = window.markdownit({
    html:        true,
    breaks:      true,
    linkify:     true,
    typographer: true, quotes: '«»„“',

    highlight: function (str, lang) {
        var esc = markdownConverter.utils.escapeHtml;
        if (lang && hljs.getLanguage(lang)) {
            try {
                return '<pre class="hljs language-' + esc(lang.toLowerCase()) + '"><code>' + hljs.highlight(lang, str, true).value + '</code></pre>';
            } catch (__) {}
        }
        return '<pre class="hljs"><code>' + esc(str) + '</code></pre>';
    }
})
    .use(window.markdownitDeflist)
    .use(window.markdownitMark)
    .use(window.markdownitFootnote)
    .use(window.markdownitTocAndAnchor); // <----------- Line 20

I also tried without "window" - it doesn't change anything:

    .use(markdownitDeflist)
    .use(markdownitMark)
    .use(markdownitFootnote)
    .use(markdownitTocAndAnchor);

Another plugins works fine for me (so, I know how to use Browserify). What's wrong with this one?

I haven't tested it without Browserify, however (because I do not know how). Does it work for someone?

Update

If I change my init.js in this way:

    .use(markdownItTocAndAnchor, {});

It will be another error:

Uncaught ReferenceError: markdownItTocAndAnchor is not defined

An in-range update of coveralls is breaking the build 🚨

The devDependency coveralls was updated from 3.0.2 to 3.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

coveralls is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: build-job: Your tests failed on CircleCI (Details).
  • continuous-integration/appveyor/branch: AppVeyor build succeeded (Details).

Release Notes for Dependency security updates

As suggested by NPM and Snyk.

Commits

The new version differs by 1 commits.

  • aa2519c dependency security audit fixes from npm & snyk (#210)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.