diff options
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown')
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/README.md | 20 | ||||
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/parser/block.go | 9 | ||||
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/parser/block_table.go | 15 |
3 files changed, 33 insertions, 11 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/README.md b/vendor/github.com/gomarkdown/markdown/README.md index 7efc1919..91397534 100644 --- a/vendor/github.com/gomarkdown/markdown/README.md +++ b/vendor/github.com/gomarkdown/markdown/README.md @@ -1,6 +1,6 @@ # Markdown Parser and HTML Renderer for Go -[![GoDoc](https://godoc.org/github.com/gomarkdown/markdown?status.svg)](https://godoc.org/github.com/gomarkdown/markdown) [![codecov](https://codecov.io/gh/gomarkdown/markdown/branch/master/graph/badge.svg)](https://codecov.io/gh/gomarkdown/markdown) +[![pkg.go.dev](https://pkg.go.dev/badge/github.com/gomarkdown/markdown)](https://pkg.go.dev/badge/github.com/gomarkdown/markdown) Package `github.com/gomarkdown/markdown` is a very fast Go library for parsing [Markdown](https://daringfireball.net/projects/markdown/) documents and rendering them to HTML. @@ -8,10 +8,10 @@ It's fast and supports common extensions. ## API Docs: -- https://godoc.org/github.com/gomarkdown/markdown : top level package -- https://godoc.org/github.com/gomarkdown/markdown/ast : defines abstract syntax tree of parsed markdown document -- https://godoc.org/github.com/gomarkdown/markdown/parser : parser -- https://godoc.org/github.com/gomarkdown/markdown/html : html renderer +- https://pkg.go.dev/github.com/gomarkdown/markdown : top level package +- https://pkg.go.dev/github.com/gomarkdown/markdown/ast : defines abstract syntax tree of parsed markdown document +- https://pkg.go.dev/github.com/gomarkdown/markdown/parser : parser +- https://pkg.go.dev/github.com/gomarkdown/markdown/html : html renderer ## Users @@ -40,7 +40,7 @@ output := markdown.ToHTML(md, nil, nil) Markdown format is loosely specified and there are multiple extensions invented after original specification was created. -The parser supports several [extensions](https://godoc.org/github.com/gomarkdown/markdown/parser#Extensions). +The parser supports several [extensions](https://pkg.go.dev/github.com/gomarkdown/markdown/parser#Extensions). Default parser uses most common `parser.CommonExtensions` but you can easily use parser with custom extension: @@ -59,7 +59,7 @@ html := markdown.ToHTML(md, parser, nil) ## Customizing HTML renderer -Similarly, HTML renderer can be configured with different [options](https://godoc.org/github.com/gomarkdown/markdown/html#RendererOptions) +Similarly, HTML renderer can be configured with different [options](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RendererOptions) Here's how to use a custom renderer: @@ -77,9 +77,9 @@ md := []byte("markdown text") html := markdown.ToHTML(md, nil, renderer) ``` -HTML renderer also supports reusing most of the logic and overriding rendering of only specifc nodes. +HTML renderer also supports reusing most of the logic and overriding rendering of only specific nodes. -You can provide [RenderNodeFunc](https://godoc.org/github.com/gomarkdown/markdown/html#RenderNodeFunc) in [RendererOptions](https://godoc.org/github.com/gomarkdown/markdown/html#RendererOptions). +You can provide [RenderNodeFunc](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RenderNodeFunc) in [RendererOptions](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RendererOptions). The function is called for each node in AST, you can implement custom rendering logic and tell HTML renderer to skip rendering this node. @@ -134,7 +134,7 @@ html := bluemonday.UGCPolicy().SanitizeBytes(maybeUnsafeHTML) ## Windows / Mac newlines The library only supports Unix newlines. If you have markdown text with possibly -Windows / Mac newlines, normalize newlines before caling this librar using +Windows / Mac newlines, normalize newlines before calling this library using `d = markdown.NormalizeNewlines(d)` ## mdtohtml command-line tool diff --git a/vendor/github.com/gomarkdown/markdown/parser/block.go b/vendor/github.com/gomarkdown/markdown/parser/block.go index 32194d9f..2b48d52d 100644 --- a/vendor/github.com/gomarkdown/markdown/parser/block.go +++ b/vendor/github.com/gomarkdown/markdown/parser/block.go @@ -1412,6 +1412,13 @@ gatherlines: // is this a nested list item? case (p.uliPrefix(chunk) > 0 && !p.isHRule(chunk)) || p.oliPrefix(chunk) > 0 || p.dliPrefix(chunk) > 0: + // if indent is 4 or more spaces on unordered or ordered lists + // we need to add leadingWhiteSpaces + 1 spaces in the beginning of the chunk + if indentIndex >= 4 && p.dliPrefix(chunk) <= 0 { + leadingWhiteSpaces := skipChar(chunk, 0, ' ') + chunk = data[ line+indentIndex - (leadingWhiteSpaces + 1) : i] + } + // to be a nested list, it must be indented more // if not, it is either a different kind of list // or the next item in the same list @@ -1484,7 +1491,7 @@ gatherlines: } // add the line into the working buffer without prefix - raw.Write(data[line+indentIndex : i]) + raw.Write(chunk) line = i } diff --git a/vendor/github.com/gomarkdown/markdown/parser/block_table.go b/vendor/github.com/gomarkdown/markdown/parser/block_table.go index 53fbd471..0bf4f4ad 100644 --- a/vendor/github.com/gomarkdown/markdown/parser/block_table.go +++ b/vendor/github.com/gomarkdown/markdown/parser/block_table.go @@ -25,6 +25,11 @@ func (p *Parser) tableRow(data []byte, columns []ast.CellAlignFlags, header bool cellStart := i + // If we are in a codespan we should discount any | we see, check for that here and skip ahead. + if isCode, _ := codeSpan(p, data[i:], 0); isCode > 0 { + i += isCode - 1 + } + for i < n && (data[i] != '|' || isBackslashEscaped(data, i)) && data[i] != '\n' { i++ } @@ -84,6 +89,11 @@ func (p *Parser) tableFooter(data []byte) bool { n := len(data) i := skipCharN(data, 0, ' ', 3) for ; i < n && data[i] != '\n'; i++ { + // If we are in a codespan we should discount any | we see, check for that here and skip ahead. + if isCode, _ := codeSpan(p, data[i:], 0); isCode > 0 { + i += isCode - 1 + } + if data[i] == '|' && !isBackslashEscaped(data, i) { colCount++ continue @@ -111,6 +121,11 @@ func (p *Parser) tableHeader(data []byte, doRender bool) (size int, columns []as headerIsUnderline := true headerIsWithEmptyFields := true for i = 0; i < len(data) && data[i] != '\n'; i++ { + // If we are in a codespan we should discount any | we see, check for that here and skip ahead. + if isCode, _ := codeSpan(p, data[i:], 0); isCode > 0 { + i += isCode - 1 + } + if data[i] == '|' && !isBackslashEscaped(data, i) { colCount++ } |