Skip to content

Commit

Permalink
Update apply.js
Browse files Browse the repository at this point in the history
More control over classnames (as described here: marp-team#233).

```js
var class = "invert pink embed"; // => "invert pink embed"
var class = "invert -pink embed"; // => "invert embed"
var class = "invert -pink embed +pink"; // => "invert embed pink"
```
  • Loading branch information
jr-k committed Oct 27, 2023
1 parent e35a0b1 commit a8e0e98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/markdown/directives/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ function _apply(md, opts = {}) {
if (marpitDirectives.lang || lang)
token.attrSet('lang', marpitDirectives.lang || lang)

if (marpitDirectives.class)
token.attrJoin('class', marpitDirectives.class)
if (marpitDirectives.class) {
token.attrJoin('class', Array.from(marpitDirectives.class.split(' ').reduce((acc, cur) => (cur.startsWith('+') ? acc.add(cur.substring(1)) : cur.startsWith('-') ? acc.delete(cur.substring(1)) : acc.add(cur), acc), new Set())).join(' ');)
}

if (marpitDirectives.color) style.set('color', marpitDirectives.color)

Expand Down

0 comments on commit a8e0e98

Please sign in to comment.