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

Unexpected behavior of Marp when importing css in a scoped style #363

Open
weshouman opened this issue Jul 14, 2023 · 1 comment
Open

Unexpected behavior of Marp when importing css in a scoped style #363

weshouman opened this issue Jul 14, 2023 · 1 comment
Labels
wontfix This will not be worked on

Comments

@weshouman
Copy link

weshouman commented Jul 14, 2023

Version of Marp Tool

marp-vscode

Operating System

Linux

Environment

  • OS version: Linux
  • Marp for VS Code: [VS Code 1.80.0] [Marp extension 4/6/2023]
  • Marp-CLI: [marp-cli v3.1.0] [marp-core v3.7.0]

How to reproduce

Using a scoped import in a section, for example:

---
<style scoped>
@import url('custom-theme-scoped.css');
</style>
# Section 1
---

Where the content of custom-theme-scoped.css is for example

h2 {
  color: orange;
}

Expected behavior

The current section only gets the h2 headers colored in orange.

Actual behavior

VSCode:
All sections gets h2 headers gets colored in Orange

Marp CLI:
No section gets the `h2 headers colored in Orange

Additional information

Reference: This question on StackOverflow addresses this issue

@weshouman weshouman added the bug Something isn't working label Jul 14, 2023
@yhatt
Copy link
Member

yhatt commented Jul 14, 2023

Unfortunately, Marp (Marpit framework) has limited support about using @import for external CSS.

By the spec of CSS, @import rule(s) for importing external styles always must be at the top of the CSS document. So @import url(...) in Marp document will work, as like as that statements are always at the top of whole in the slide document. So <style scoped> is not working because @import will always be loaded first than theme styles and other inline styles.

In addition, @import will bypass scoping the output CSS itself when building Marp slide. CSS scoping is important for making a boundary of Marp app styles and slide styles. If bypassed, the outside of slides by Marp apps may not be rendered correctly, or may see inconsistent slide results by apps (as you have seen).

For better result, you should make inlining external CSS.

@yhatt yhatt added wontfix This will not be worked on and removed bug Something isn't working labels Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants