package util
Import Path
github.com/yuin/goldmark/util (on go.dev)
Dependency Relation
imports 10 packages, and imported by 7 packages
Involved Source Files
html5entities.go
unicode_case_folding.go
Package util provides utility functions for the goldmark.
util_cjk.go
util_unsafe.go
Package-Level Type Names (total 6)
A BufWriter is a subset of the bufio.Writer .
( BufWriter) Available() int
( BufWriter) Buffered() int
( BufWriter) Flush() error
( BufWriter) Write([]byte) (int, error)
( BufWriter) WriteByte(c byte) error
( BufWriter) WriteRune(r rune) (size int, err error)
( BufWriter) WriteString(s string) (int, error)
*github.com/libp2p/go-buffer-pool.Writer
*bufio.Writer
net/http/internal.FlushAfterChunkWriter
BufWriter : github.com/apache/thrift/lib/go/thrift.Flusher
BufWriter : github.com/miekg/dns.Writer
BufWriter : github.com/quic-go/quic-go/quicvarint.Writer
BufWriter : gorm.io/gorm/clause.Writer
BufWriter : internal/bisect.Writer
BufWriter : io.ByteWriter
BufWriter : io.StringWriter
BufWriter : io.Writer
func github.com/yuin/goldmark/renderer/html.RenderAttributes(w BufWriter, node ast.Node, filter BytesFilter)
func github.com/yuin/goldmark/renderer/html.Writer.RawWrite(writer BufWriter, source []byte)
func github.com/yuin/goldmark/renderer/html.Writer.SecureWrite(writer BufWriter, source []byte)
func github.com/yuin/goldmark/renderer/html.Writer.Write(writer BufWriter, source []byte)
BytesFilter is a efficient data structure for checking whether bytes exist or not.
BytesFilter is thread-safe.
Add adds given bytes to this set.
Contains return true if this set contains given bytes, otherwise false.
Extend copies this filter and adds given bytes to new filter.
func NewBytesFilter(elements ...[]byte) BytesFilter
func BytesFilter.Extend(...[]byte) BytesFilter
func github.com/yuin/goldmark/renderer/html.RenderAttributes(w BufWriter, node ast.Node, filter BytesFilter)
var github.com/yuin/goldmark/extension.DefinitionDescriptionAttributeFilter
var github.com/yuin/goldmark/extension.DefinitionListAttributeFilter
var github.com/yuin/goldmark/extension.DefinitionTermAttributeFilter
var github.com/yuin/goldmark/extension.StrikethroughAttributeFilter
var github.com/yuin/goldmark/extension.TableAttributeFilter
var github.com/yuin/goldmark/extension.TableHeaderAttributeFilter
var github.com/yuin/goldmark/extension.TableRowAttributeFilter
var github.com/yuin/goldmark/extension.TableTdCellAttributeFilter
var github.com/yuin/goldmark/extension.TableThCellAttributeFilter
var github.com/yuin/goldmark/renderer/html.BlockquoteAttributeFilter
var github.com/yuin/goldmark/renderer/html.CodeAttributeFilter
var github.com/yuin/goldmark/renderer/html.EmphasisAttributeFilter
var github.com/yuin/goldmark/renderer/html.GlobalAttributeFilter
var github.com/yuin/goldmark/renderer/html.HeadingAttributeFilter
var github.com/yuin/goldmark/renderer/html.ImageAttributeFilter
var github.com/yuin/goldmark/renderer/html.LinkAttributeFilter
var github.com/yuin/goldmark/renderer/html.ListAttributeFilter
var github.com/yuin/goldmark/renderer/html.ListItemAttributeFilter
var github.com/yuin/goldmark/renderer/html.ParagraphAttributeFilter
var github.com/yuin/goldmark/renderer/html.ThematicAttributeFilter
A CopyOnWriteBuffer is a byte buffer that copies buffer when
it need to be changed.
Append appends given bytes to the buffer.
Append copy buffer at the first time.
AppendByte appends given bytes to the buffer.
AppendByte copy buffer at the first time.
AppendString appends given string to the buffer.
AppendString copy buffer at the first time.
Bytes returns bytes of this buffer.
IsCopied returns true if buffer has been copied, otherwise false.
Write writes given bytes to the buffer.
Write allocate new buffer and clears it at the first time.
WriteByte writes the given byte to the buffer.
WriteByte allocate new buffer and clears it at the first time.
WriteString writes given string to the buffer.
WriteString allocate new buffer and clears it at the first time.
*CopyOnWriteBuffer : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice
*CopyOnWriteBuffer : io.ByteWriter
func NewCopyOnWriteBuffer(buffer []byte) CopyOnWriteBuffer
An HTML5Entity struct represents HTML5 entitites.
Characters []byte
CodePoints []int
Name string
func LookUpHTML5EntityByName(name string) (*HTML5Entity, bool)
PrioritizedSlice is a slice of the PrioritizedValues.
Remove removes the given value from this slice.
Sort sorts the PrioritizedSlice in ascending order.
func PrioritizedSlice.Remove(v interface{}) PrioritizedSlice
A PrioritizedValue struct holds pair of an arbitrary value and a priority.
Priority is a priority of the value.
Value is an arbitrary value that you want to prioritize.
func Prioritized(v interface{}, priority int) PrioritizedValue
func github.com/yuin/goldmark/parser.DefaultBlockParsers() []PrioritizedValue
func github.com/yuin/goldmark/parser.DefaultInlineParsers() []PrioritizedValue
func github.com/yuin/goldmark/parser.DefaultParagraphTransformers() []PrioritizedValue
func github.com/yuin/goldmark/parser.WithASTTransformers(ps ...PrioritizedValue) parser.Option
func github.com/yuin/goldmark/parser.WithBlockParsers(bs ...PrioritizedValue) parser.Option
func github.com/yuin/goldmark/parser.WithInlineParsers(bs ...PrioritizedValue) parser.Option
func github.com/yuin/goldmark/parser.WithParagraphTransformers(ps ...PrioritizedValue) parser.Option
func github.com/yuin/goldmark/renderer.WithNodeRenderers(ps ...PrioritizedValue) renderer.Option
Package-Level Functions (total 50)
BytesToReadOnlyString returns a string converted from given bytes.
DedentPosition dedents lines by the given width.
Deprecated: This function has bugs. Use util.IndentPositionPadding and util.FirstNonSpacePosition.
DedentPositionPadding dedents lines by the given width.
This function is mostly same as DedentPosition except this function
takes account into additional paddings.
Deprecated: This function has bugs. Use util.IndentPositionPadding and util.FirstNonSpacePosition.
DoFullUnicodeCaseFolding performs full unicode case folding to given bytes.
EastAsianWidth returns the east asian width of the given rune.
See https://www.unicode.org/reports/tr11/tr11-36.html
EscapeHTML escapes characters that should be escaped in HTML text.
EscapeHTMLByte returns HTML escaped bytes if the given byte should be escaped,
otherwise nil.
FindClosure returns a position that closes the given opener.
If codeSpan is set true, it ignores characters in code spans.
If allowNesting is set true, closures correspond to nested opener will be
ignored.
Deprecated: This function can not handle newlines. Many elements
can be existed over multiple lines(e.g. link labels).
Use text.Reader.FindClosure.
FindEmailIndex returns a stop index value if the given bytes seem an email address.
FindURLIndex returns a stop index value if the given bytes seem an URL.
This function is equivalent to [A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\x00-\x20]* .
FirstNonSpacePosition returns a position line that is a first nonspace
character.
IndentPosition searches an indent position with the given width for the given line.
If the line contains tab characters, paddings may be not zero.
currentPos==0 and width==2:
position: 0 1
[TAB]aaaa
width: 1234 5678
width=2 is in the tab character. In this case, IndentPosition returns
(pos=1, padding=2).
IndentPositionPadding searches an indent position with the given width for the given line.
This function is mostly same as IndentPosition except this function
takes account into additional paddings.
IndentWidth calculate an indent width for the given line.
IsAlphaNumeric returns true if the given character is a alphabet or a numeric, otherwise false.
IsBlank returns true if the given string is all space characters.
IsEastAsianWideRune returns trhe if the given rune is an east asian wide character, otherwise false.
IsEscapedPunctuation returns true if character at a given index i
is an escaped punctuation, otherwise false.
IsHexDecimal returns true if the given character is a hexdecimal, otherwise false.
IsNumeric returns true if the given character is a numeric, otherwise false.
IsPunct returns true if the given character is a punctuation, otherwise false.
IsPunctRune returns true if the given rune is a punctuation, otherwise false.
IsSpace returns true if the given character is a space, otherwise false.
IsSpaceDiscardingUnicodeRune returns true if the given rune is space-discarding unicode character, otherwise false.
See https://www.w3.org/TR/2020/WD-css-text-3-20200429/#space-discard-set
IsSpaceRune returns true if the given rune is a space, otherwise false.
LookUpHTML5EntityByName returns (an HTML5Entity, true) if an entity named
given name is found, otherwise (nil, false).
NewBytesFilter returns a new BytesFilter.
NewCopyOnWriteBuffer returns a new CopyOnWriteBuffer.
Prioritized returns a new PrioritizedValue.
ReadWhile read the given source while pred is true.
ReplaceSpaces replaces sequence of spaces with the given repl.
ResolveEntityNames resolve entity references like 'ö" .
ResolveNumericReferences resolve numeric references like 'Ӓ" .
StringToReadOnlyBytes returns bytes converted from given string.
TabWidth calculates actual width of a tab at the given position.
ToLinkReference converts given bytes into a valid link reference string.
ToLinkReference performs unicode case folding, trims leading and trailing spaces, converts into lower
case and replace spaces with a single space character.
ToRune decode given bytes start at pos and returns a rune.
ToValidRune returns 0xFFFD if the given rune is invalid, otherwise v.
TrimLeft trims characters in the given s from head of the source.
bytes.TrimLeft offers same functionalities, but bytes.TrimLeft
allocates new buffer for the result.
TrimLeftLength returns a length of leading specified characters.
TrimLeftSpace returns a subslice of the given string by slicing off all leading
space characters.
TrimLeftSpaceLength returns a length of leading space characters.
TrimRight trims characters in the given s from tail of the source.
TrimRightLength returns a length of trailing specified characters.
TrimRightSpace returns a subslice of the given string by slicing off all trailing
space characters.
TrimRightSpaceLength returns a length of trailing space characters.
UnescapePunctuations unescapes blackslash escaped punctuations.
URLEscape escape the given URL.
If resolveReference is set true:
1. unescape punctuations
2. resolve numeric references
3. resolve entity references
URL encoded values (%xx) are kept as is.
UTF8Len returns a byte length of the utf-8 character.
VisualizeSpaces visualize invisible space characters.
![]() |
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. |