This is a port of remark-cjk-friendly / markdown-it-cjk-friendly for goldmark as an external extension.
package main
import (
"github.com/yuin/goldmark"
"github.com/tats-u/goldmark-cjk-friendly/v2"
)
func main() {
md := goldmark.New(
goldmark.WithExtensions(
cjkfriendly.CJKFriendlyEmphasis,
),
)
}CJKFriendlyEmphasis: The basic extension without GFM strikethrough supportCJKFriendlyEmphasisAndStrikethrough: The basic extension with GFM strikethrough support. You do not need to add goldmark'sStrikethroughextension if you use this extension.CJKFriendlyStrikethrough:CJKFriendlyEmphasisAndStrikethrough-CJKFriendlyEmphasis. However, you do not need to prefer this extension toCJKFriendlyEmphasisAndStrikethroughsince you will want to useCJKFriendlyEmphasisandCJKFriendlyStrikethroughtogether. Use this extension only if you want to switch between this extension and goldmark's plainStrikethroughextension.
Important
/v2 here is required to use the latest version of this module.
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/v2"
)
func main() {
md := goldmark.New(
goldmark.WithExtensions(
cjkfriendly.CJKFriendlyEmphasis,
extension.NewCJK(extension.WithEscapedSpace()), // or extension.CJK,
),
)
}MIT (same as goldmark)