Introduction to the remark CLI

John Otander
InstructorJohn Otander
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

You can use the remark CLI to inspect the AST, run plugins, or lint your markdown documents. It can be used in your build scripts to generate HTML or ensure your markdown style guide is adhered to.

  • Inspect the AST: remark document.md --inspect
  • Use a plugin: remark document.md --use toc
  • Overwrite your document after the plugin runs: remark document.md --use toc -o
  • Lint a document: remark document.md --frail --use preset-lint-markdown-style-guide

John Otander: [00:00] Remark comes with the command line interface, or CLI, that can be used to automate tasks. First, just go ahead and inspect the document. Inspect option logs out the entire AST, which can be used for debugging plugins.

[00:15] As we also see here, we have the "Table of contents" heading and no children beneath it. We can automatically populate this by using the remark toc plugin as part of the CLI command. Now the table of contents has been populated.

[00:29] However, if you run the inspect command one more time, we'll see that the table of contents has not been persisted. That's because we didn't specify the output.

[00:37] With the output options specified, we can now inspect one more time and see that it has been populated. In addition to plugins that manipulate your markdown, you can also use plugins for linting.

[00:48] Here, we'll lint against our markdown style guide. When we run the command, we'll see a list of errors that have been generated based off our preferences. We can additionally run commands based off whether the linting passed or failed. Though for this to work we'll have to specify the frail option, which means it will error out. This results in us seeing fail rather than pass.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today