Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Integrate markdown styles into web components, Markdown CSS styles will not be conflicted.

License

NotificationsYou must be signed in to change notification settings

jaywcjlove/markdown-style

Repository files navigation

Buy me a coffeeCIjsDelivr CDNnpm versionOpen in unpkg

Integrate markdown styles into web components, Markdown CSS styles will not be conflicted. The minimal amount of CSS to replicate the GitHub Markdown style. Support dark-mode/night mode.

Installation

npm install --save @wcj/markdown-style

Or load the ES module directly through unpkg

unpkg.com CDN:

<scriptsrc="https://unpkg.com/@wcj/markdown-style"></script>

Skypack CDN:

<scriptsrc="https://cdn.skypack.dev/@wcj/markdown-style"></script>

Usage

Use it in your HTML:

<markdown-style><!-- markdown html is here --><h1>Markdown HTML</h1></markdown-style>

Learn about web componentshere.

Using it in your React:

importReactfrom'react';import'@wcj/markdown-style';functionDemo(){return(<markdown-style><h1>Markdown Style</h1></markdown-style>);}

Convert markdown to html and add markdown style to it:

<scriptsrc="https://unpkg.com/@wcj/markdown-to-html/dist/markdown.min.js"></script><scriptsrc="https://unpkg.com/@wcj/markdown-style"></script><markdown-style>\```jsximport React from 'react';import 'markdown-style';function Demo() {  return (<markdown-style><h1>Markdown Style</h1></markdown-style>  );}\```</markdown-style><script>constmdstr=document.querySelector('markdown-style');mdstr.innerHTML=markdown.default(mdstr.textContent);</script>

Support dark-mode/night-mode

By default, thedark-mode is automatically switched according to the system. If you need to switch manually, just set thedata-color-mode="dark" parameter for<html>.

<htmldata-color-mode="dark">
document.documentElement.setAttribute('data-color-mode','dark')document.documentElement.setAttribute('data-color-mode','light')

Set the theme, do not automatically switch with the system:

<markdown-styletheme="dark"><h1>Markdown Style</h1></markdown-style>

Disable internal theme switching functionality

<markdown-styletheme-auto-switch-disabledtheme="dark"><h1>Markdown Style</h1></markdown-style>

Contributors

As always, thanks to our amazing contributors!

Made withgithub-action-contributors.

License

Licensed under theMIT License.

About

Integrate markdown styles into web components, Markdown CSS styles will not be conflicted.

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors3

    •  
    •  
    •  

    [8]ページ先頭

    ©2009-2025 Movatter.jp