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

Custom theme support #59

Merged
merged 15 commits into from
Jul 29, 2019
Merged

Custom theme support #59

merged 15 commits into from
Jul 29, 2019

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Jul 17, 2019

Resolves #39. I added markdown.marp.themes configuration property to specify paths for custom theme CSS. It has the same rule as VS code built-in configuration markdown.styles: Specified paths must be URLs and relative paths from workspace directory.

lemon-theme

Marp requires the actual content of files unlike Markdown preview. Thus, we have to add the logic of resolving themes from URL or workspace/parent directory of Markdown to support Marp's custom theme in preview.

Resolving paths looks like difficult because we cannot access to the original document of VS Code in the context of markdown-it extension normally. But I found a trick that using normalizeLink method defined to markdown-it instance can resolve its workspace directory or parent directory. We use this trick to get same behavior of markdown.styles.

Advantage of markdown.marp.themes is accepting external URL, very easy way to get community-driven CSS themes.

// Use custom theme by URL
{
  "markdown.marp.themes": ["https://raw.githubusercontent.com/yhatt/marp-cli-example/master/themes/example.css"]
}

ToDo

  • Allow using custom theme CSS while exporting
  • Add tests

@yhatt yhatt marked this pull request as ready for review July 27, 2019 12:09
@yhatt
Copy link
Member Author

yhatt commented Jul 27, 2019

CI was passed by filled unit tests.

@yhatt yhatt merged commit b356bd2 into master Jul 29, 2019
@yhatt yhatt deleted the custom-theme branch July 29, 2019 10:52
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.

Custom theme
1 participant