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 style plugins for appending additional styles to theme #25

Merged
merged 19 commits into from
May 27, 2018

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented May 16, 2018

This PR will add style plugins for appending additional styles to theme. Marpit will parse <style> elements and its content as like as comment plugin, and parsed styles will append to a packing CSS. In pre-released Marp, using <style> elements is one of customization way of theme born from community.

The customized style within a markdown would be able to work with the same context of Marpit theme CSS.

Example

/* @theme example */
strong { color: red; }
---
theme: example
---

<style>
strong { color: blue; }
</style>

**The example**

In this case, the <strong> element will be colored blue.

Compiled CSS

/* @theme example */
div.marpit > section > strong { color: red; }
/* Append style */
div.marpit > section > strong { color: blue; }

The user specified style will append to the last of packed theme and be scoped automatically as same as a theme.

ToDo

  • Add style elements plugin
  • Append parsed style
  • Support multiple <style> elements
  • Support style global directive to keep compatibility with markdown for document
  • Add test cases

@yhatt yhatt changed the title [Work in progress] Add inline style elements plugin [Work in progress] Add style elements plugin May 24, 2018
@yhatt
Copy link
Member Author

yhatt commented May 24, 2018

To avoid more parsing to already parsed tokens, I have changed the approach parsing <style> elements to a block rule as same as markdown-it's html parsing.

This approach will be able to apply #28 too.

@yhatt yhatt changed the title [Work in progress] Add style elements plugin Add style elements plugin May 25, 2018
@yhatt yhatt changed the title Add style elements plugin Add style plugins for appending additional styles to theme May 26, 2018
@yhatt yhatt merged commit 79d61e0 into master May 27, 2018
@yhatt yhatt deleted the inline-style-elements branch May 27, 2018 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant