Skip to content

How to highlight rows in markdown code blocks? #105

Answered by yhatt
hakib asked this question in Q&A
Discussion options

You must be logged in to vote
// marp.config.js
const { Marp } = require('@marp-team/marp-core')
const highlightLines = require('markdown-it-highlight-lines')

module.exports = {
  engine: (opts) => new Marp(opts).use(highlightLines),
}
# markdown.md

```js {1,2,4-5}
function foo() {
  return bar().then((res) => {
    return res.doSomething()
  })
}
```

<style>
.highlighted-line {
  background-color: #ff0;
  display: block;
  margin: 0 -16px;
  padding: 0 16px;
}
</style>
npm i --save @marp-team/marp-core @marp-team/marp-cli markdown-it-highlight-lines
npx marp -c ./marp.config.js markdown.md

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@hakib
Comment options

@yhatt
Comment options

@hakib
Comment options

Answer selected by hakib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants