Skip to content

tats-u/goldmark-cjk-friendly

Repository files navigation

goldmark-cjk-friendly

https://pkg.go.dev/github.com/tats-u/goldmark-cjk-friendly https://goreportcard.com/report/github.com/tats-u/goldmark-cjk-friendly Release

This is a port of remark-cjk-friendly / markdown-it-cjk-friendly for goldmark as an external extension.

Usage

package main

import (
    "github.com/yuin/goldmark"
    "github.com/tats-u/goldmark-cjk-friendly"
)

func main() {
    md := goldmark.New(
        goldmark.WithExtensions(
            cjkfriendly.CJKFriendlyEmphasis,
        ),
    )
}
  • CJKFriendlyEmphasis: The basic extension without GFM strikethrough support
  • CJKFriendlyEmphasisAndStrikethrough: The basic extension with GFM strikethrough support. You do not need to add goldmark's Strikethrough extension if you use this extension.
  • CJKFriendlyStrikethrough: CJKFriendlyEmphasisAndStrikethrough - CJKFriendlyEmphasis. However, you do not need to prefer this extension to CJKFriendlyEmphasisAndStrikethrough since you will want to use CJKFriendlyEmphasis and CJKFriendlyStrikethrough together. Use this extension only if you want to switch between this extension and goldmark's plain Strikethrough extension.

Comparison with goldmark's CJK extension (WithEscapedSpace)

Combining this extension with goldmark's CJK extension (WithEscapedSpace) is welcome. They are not mutually exclusive. If you meet a case that cannot be emphasized with this extension, you can rely on goldmark's CJK extension as a last resort:

a\ **()**\ aあ**()**

This extension can handle the case あ**()**あ, but cannot handle the case a**()**a for the compatibility with the plain CommonMark. You can add \ outside the emphasis marks to delegate the fix to goldmark's CJK extension.

package main

import (
    "github.com/yuin/goldmark"
    "github.com/yuin/goldmark/extension"
    "github.com/tats-u/goldmark-cjk-friendly"
)

func main() {
    md := goldmark.New(
        goldmark.WithExtensions(
            cjkfriendly.CJKFriendlyEmphasis,
            extension.NewCJK(extension.WithEscapedSpace()), // or extension.CJK,
        ),
    )
}

License

MIT (same as goldmark)

About

goldmark port of https://github.com/tats-u/markdown-cjk-friendly

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages