Source File
cjk.go
Belonging Package
github.com/yuin/goldmark/extension
package extensionimport ()// A CJKOption sets options for CJK support mostly for HTML based renderers.type CJKOption func(*cjk)// A EastAsianLineBreaks is a style of east asian line breaks.type EastAsianLineBreaks intconst (//EastAsianLineBreaksNone renders line breaks as it is.EastAsianLineBreaksNone EastAsianLineBreaks = iota// EastAsianLineBreaksSimple is a style where soft line breaks are ignored// if both sides of the break are east asian wide characters.EastAsianLineBreaksSimple// EastAsianLineBreaksCSS3Draft is a style where soft line breaks are ignored// even if only one side of the break is an east asian wide character.EastAsianLineBreaksCSS3Draft)// WithEastAsianLineBreaks is a functional option that indicates whether softline breaks// between east asian wide characters should be ignored.// style defauts to [EastAsianLineBreaksSimple] .func ( ...EastAsianLineBreaks) CJKOption {return func( *cjk) {if len() == 0 {.EastAsianLineBreaks = EastAsianLineBreaksSimplereturn}.EastAsianLineBreaks = [0]}}// WithEscapedSpace is a functional option that indicates that a '\' escaped half-space(0x20) should not be rendered.func () CJKOption {return func( *cjk) {.EscapedSpace = true}}type cjk struct {EastAsianLineBreaks EastAsianLineBreaksEscapedSpace bool}// CJK is a goldmark extension that provides functionalities for CJK languages.var CJK = NewCJK(WithEastAsianLineBreaks(), WithEscapedSpace())// NewCJK returns a new extension with given options.func ( ...CJKOption) goldmark.Extender {:= &cjk{EastAsianLineBreaks: EastAsianLineBreaksNone,}for , := range {()}return}func ( *cjk) ( goldmark.Markdown) {.Renderer().AddOptions(html.WithEastAsianLineBreaks(html.EastAsianLineBreaks(.EastAsianLineBreaks)))if .EscapedSpace {.Renderer().AddOptions(html.WithWriter(html.NewWriter(html.WithEscapedSpace()))).Parser().AddOptions(parser.WithEscapedSpace())}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |