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

Add data-marpit-svg attribute to SVG element outputted by inline SVG mode #115

Merged
merged 3 commits into from
Dec 28, 2018
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Support setting background color by Markdown image syntax ([#92](https://github.com/marp-team/marpit/issues/92), [#113](https://github.com/marp-team/marpit/pull/113))
- Add `data-marpit-svg` attribute to SVG element outputted by inline SVG mode ([#115](https://github.com/marp-team/marpit/pull/115))

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions docs/inline-svg.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
When you set [`inlineSVG: true` in Marpit constructor option](/usage#triangular_ruler-inline-svg-slide), each `<section>` elements are wrapped with inline SVG.

```html
<svg viewBox="0 0 1280 960">
<svg data-marpit-svg="" viewBox="0 0 1280 960">
<foreignObject width="1280" height="960">
<section><h1>Page 1</h1></section>
</foreignObject>
</svg>
<svg viewBox="0 0 1280 960">
<svg data-marpit-svg="" viewBox="0 0 1280 960">
<foreignObject width="1280" height="960">
<section><h1>Page 2</h1></section>
</foreignObject>
Expand All @@ -27,7 +27,7 @@ You may delegate a logic of pixel-perfect scaling for slide page to SVG. You hav

```css
/* Fit slide page to viewport */
svg {
svg[data-marpit-svg] {
display: block;
width: 100vw;
height: 100vh;
Expand Down
1 change: 1 addition & 0 deletions src/markdown/inline_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function inlineSVG(md, marpit) {
'marpit_inline_svg',
{
tag: 'svg',
'data-marpit-svg': '',
viewBox: `0 0 ${w} ${h}`,
open: { meta: { marpitSlideElement: 1 } },
close: { meta: { marpitSlideElement: -1 } },
Expand Down
2 changes: 1 addition & 1 deletion src/postcss/advanced_background.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ section[data-marpit-advanced-background="pseudo"] {
}

section[data-marpit-advanced-background="pseudo"],
:marpit-container > svg > foreignObject[data-marpit-advanced-background="pseudo"] {
:marpit-container > svg[data-marpit-svg] > foreignObject[data-marpit-advanced-background="pseudo"] {
pointer-events: none !important;
}

Expand Down
2 changes: 1 addition & 1 deletion src/postcss/printable.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const plugin = postcss.plugin('marpit-postcss-printable', opts => css => {
color-adjust: exact !important;
}

:marpit-container > svg {
:marpit-container > svg[data-marpit-svg] {
display: block;
height: 100vh;
width: 100vw;
Expand Down
4 changes: 3 additions & 1 deletion test/markdown/inline_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ describe('Marpit inline SVG plugin', () => {
const $ = render(md(), '# test\n\n---\n\n# test')

expect(
$('svg[viewBox] > foreignObject[width][height] > section')
$(
'svg[viewBox][data-marpit-svg] > foreignObject[width][height] > section'
)
).toHaveLength(2)
})

Expand Down