Codimd: Embed markdownlint

Created on 14 Aug 2019  路  8Comments  路  Source: hackmdio/codimd

@DavidAnson created a real nice markdown linter: https://github.com/DavidAnson/markdownlint. See a demo at https://dlaa.me/markdownlint/.

In Visual Studio Code, it displays as follows:

grafik

One can also disable certain rules inline: <!-- markdownlint-disable MD003 MD022 MD033 -->

grafik

For reference: MD003 MD022 MD033

This somehow refs https://github.com/hackmdio/codimd/issues/311. However, This issue is about markdown, not the YAML header.

Most helpful comment

Screen Shot 2019-08-16 at 1 47 12 AM

A quick PoC!

All 8 comments

Thanks, @koppor ! If you decide to use markdownlint and have any issues, I can try to help.

This is interesting! The editor of CodiMD is built on top of CodeMirror, which already has some linter addons out there:

All we need to to is:

  1. Write a markdownlint codemirror addon
  2. Plug into CodiMD
  3. Add a status bar item (TBD) to toggle this functionality

Screen Shot 2019-08-16 at 1 47 12 AM

A quick PoC!

Hi @DavidAnson, I've opened a PR for this feature and I have some findings to share with.

I bundled markdownlint with webpack's NormalModuleReplacementPlugin

    new webpack.NormalModuleReplacementPlugin(
      /^url$/,
      path.resolve(__dirname, './public/js/url.js')
    )

and the content of url.js is:

exports.URL = window.URL

It seems a little bit hacky but it should do the same thing as markdown-it-stub.js does. I also notice that markdownlint already provide build-demo command for frontend build.

Is there any plan to distribute markdownlint-browser.js with npm module? This will make us use markdownlint in frontend JavaScript more easily. Thank you.

@yukaii I thought the front-end build was only really useful for my demo app, so don鈥檛 include it in the npm package. If you confirm the markdownlint-browser.js file that鈥檚 created today by the build-demo script is useful in this scenario, I鈥檓 happy to include it in the next release!

Verified it's working via additional markdown-it stub and webpack script-loader:

window.markdownit = require('markdown-it')
require('script-loader!markdownlint')
resolve: {
  alias: {
    markdownlint: path.join(__dirname, 'public/vendor/markdownlint-browser.min.js')
  }
}

@DavidAnson Yes please add it to next release 馃槏

Great, thank you for checking! I will add that file in the next release.

Update: markdownlint-browser.js should be available in the npm package for markdownlint with the next release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

almereyda picture almereyda  路  4Comments

Nebukadneza picture Nebukadneza  路  3Comments

nitwhiz picture nitwhiz  路  4Comments

LukasKalbertodt picture LukasKalbertodt  路  4Comments

sagesharp picture sagesharp  路  4Comments