Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CSS container query support by default #360

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- Enabled [`cssContainerQuery` constructor option from Marpit framework](https://marpit-api.marp.app/marpit#Marpit) by default ([#360](https://github.com/marp-team/marp-core/pull/360))

### Changed

- Upgrade Marpit to [v2.6.1](https://github.com/marp-team/marpit/releases/v2.6.1) ([#358](https://github.com/marp-team/marp-core/pull/358))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _We will only explain features extended in marp-core._ Please refer to [Marpit f
**Marp Markdown** is a custom Markdown flavor based on [Marpit](https://marpit.marp.app) and [CommonMark](https://commonmark.org/). Following are principle differences from the original:

- **Marpit**
- Enabled [inline SVG slide](https://marpit.marp.app/inline-svg) and [loose YAML parsing](https://marpit-api.marp.app/marpit#Marpit) by default.
- Enabled [inline SVG slide](https://marpit.marp.app/inline-svg), [CSS container query support and loose YAML parsing](https://marpit-api.marp.app/marpit#Marpit) by default.

* **CommonMark**
- For making secure, we will deny most of HTML tags used in Markdown by default. Allowed HTML tags are `<br>` only for now.
Expand Down
1 change: 1 addition & 0 deletions src/marp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class Marp extends Marpit {
}

super({
cssContainerQuery: true,
inlineSVG: true,
looseYAML: true,
math: true,
Expand Down
24 changes: 24 additions & 0 deletions test/marp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ describe('Marp', () => {
})
})

describe('Marpit options', () => {
describe('cssContainerQuery option', () => {
it('is enabled by default', () => {
const { css } = marp().render('')
expect(css).toContain('container-type:size')
})

it('can disable by setting cssContainerQuery constructor option as false', () => {
const { css } = marp({ cssContainerQuery: false }).render('')
expect(css).not.toContain('container-type')
})

it('can assign container name by setting cssContainerQuery constructor option as string or the array of strings', () => {
const single = marp({ cssContainerQuery: 'name' }).render('')
expect(single.css).toContain('container-type:size')
expect(single.css).toContain('container-name:name')

const multi = marp({ cssContainerQuery: ['name1', 'name2'] }).render('')
expect(multi.css).toContain('container-type:size')
expect(multi.css).toContain('container-name:name1 name2')
})
})
})

describe('emoji option', () => {
describe('shortcode option', () => {
it('converts emoji shorthand to twemoji image by default', () => {
Expand Down