zenn-editor

repository·canary·Indexed 20 days ago

https://github.com/zenn-dev/zenn-editor

A collection of packages to replicate the Zenn Markdown ecosystem. It includes zenn-cli for local previewing, zenn-markdown-html for Node.js Markdown-to-HTML conversion, zenn-content-css for Zenn-style styling, zenn-embed-elements for React-based web components (such as KaTeX), and zenn-model for handling Zenn-specific data structures and metadata.

Tokens
21.2K
Snippets
101
Records
121
Agent score
70%

What's inside zenn-editor

  1. Overview of zenn-editor packages

    canary

    The zenn-editor repository manages a collection of packages used to implement the Zenn Markdown style. These packages can be used to build tools similar to Zenn CLI or the Zenn VSCode extension.

    Available Packages

    Package NameDescription
    zenn-cliCLI for displaying local articles and books
    zenn-content-cssStyles for Markdown previews
    zenn-embed-elementsWeb Components for embedded elements (e.g., Tweets, Mermaid)
    zenn-markdown-htmlConverts Markdown to HTML
    zenn-modelHandles article and book data
  2. Convert Markdown to HTML with zenn-markdown-html

    canary

    Use zenn-markdown-html to convert Markdown content into HTML that supports Zenn's unique syntax. This package provides two main interfaces depending on the level of decoration required:

    1. markdownToHtml: Full support for Zenn articles, books, and comments. This is the standard choice for rich content.
    2. markdownToSimpleHtml: Limited support for simple decorations, suitable for fixed messages in publications.

    Refer to the Zenn Markdown Guide for a complete list of supported syntax.

    import markdownToHtml from 'zenn-markdown-html';
    const html = markdownToHtml(markdown);
    
    // Or for limited decoration:
    import { markdownToSimpleHtml } from 'zenn-markdown-html';
    const simpleHtml = markdownToSimpleHtml(markdown);
  3. Syntax highlighting styles in zenn-content-css

    canary

    The package provides different SCSS files for syntax highlighting depending on the engine used:

    • _shiki.scss: Current standard styles for Shiki.
    • _prism.scss: Legacy styles for Prism.js. This is kept for backward compatibility with existing articles that use Prism.js but is deprecated and may be removed in the future.
  4. Use Link Cards for URL embedding

    canary

    The Zenn Markdown style automatically converts standalone URLs into rich Link Cards. This behavior depends on the context of the URL within the document.

    Default Behavior

    When a URL is placed on its own line, it is converted into a Link Card.

    GitHub Integration

    URLs pointing to GitHub repositories (e.g., https://github.com/user/repo) are specifically recognized and rendered as GitHub repository cards.

    Limitations and Exceptions

    • Lists: URLs inside list items (e.g., - https://example.com) are not converted to Link Cards; they remain as plain text or standard Markdown links.
    • Anchor Text: Standard Markdown links like [text](https://url.com) are not converted to Link Cards.
    • Message Blocks: URLs inside :::message blocks are not converted to Link Cards.
    • HTML Tags: Raw HTML tags (like <iframe>) are not processed as embeddable content by the Zenn Markdown parser.
    ### Default Link Card
    https://zenn.dev
    
    ### GitHub Repository Card
    https://github.com/zenn-dev/zenn-editor
  5. Apply inline styles and comments

    canary

    Use standard Markdown for styles and HTML comments for private notes:

    • Italic: *text* or _text_.
    • Bold: **text**.
    • Strikethrough: ~~text~~.
    • Inline Code: `code`.
    • Comments: <!-- comment --> (Note: Multi-line comments are not supported; these will not appear on the published page).
    *Italic* **Bold** ~~Strikethrough~~ `code`
    
    <!-- TODO: note -->
    *イタリック*
    **太字**
    ~~打ち消し線~~
    インラインで`code`を挿入する
    
    <!-- TODO: ◯◯について追記する -->