summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-08-05 20:43:19 +0200
committerGitHub <noreply@github.com>2023-08-05 20:43:19 +0200
commit56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (patch)
treeb1355645342667209263cbd355dc0b4254f1e8fe /vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go
parent9459495484d6e06a3d46de64fccd8d06f7ccc72c (diff)
downloadmatterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.gz
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.bz2
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.zip
Update dependencies and remove old matterclient lib (#2067)HEADmaster
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go78
1 files changed, 0 insertions, 78 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go b/vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go
deleted file mode 100644
index 3c7f2d1c..00000000
--- a/vendor/github.com/mattermost/mattermost-server/v5/shared/markdown/inspect.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See LICENSE.txt for license information.
-
-package markdown
-
-// Inspect traverses the markdown tree in depth-first order. If f returns true, Inspect invokes f
-// recursively for each child of the block or inline, followed by a call of f(nil).
-func Inspect(markdown string, f func(interface{}) bool) {
- document, referenceDefinitions := Parse(markdown)
- InspectBlock(document, func(block Block) bool {
- if !f(block) {
- return false
- }
- switch v := block.(type) {
- case *Paragraph:
- for _, inline := range MergeInlineText(v.ParseInlines(referenceDefinitions)) {
- InspectInline(inline, func(inline Inline) bool {
- return f(inline)
- })
- }
- }
- return true
- })
-}
-
-// InspectBlock traverses the blocks in depth-first order, starting with block. If f returns true,
-// InspectBlock invokes f recursively for each child of the block, followed by a call of f(nil).
-func InspectBlock(block Block, f func(Block) bool) {
- if !f(block) {
- return
- }
- switch v := block.(type) {
- case *Document:
- for _, child := range v.Children {
- InspectBlock(child, f)
- }
- case *List:
- for _, child := range v.Children {
- InspectBlock(child, f)
- }
- case *ListItem:
- for _, child := range v.Children {
- InspectBlock(child, f)
- }
- case *BlockQuote:
- for _, child := range v.Children {
- InspectBlock(child, f)
- }
- }
- f(nil)
-}
-
-// InspectInline traverses the blocks in depth-first order, starting with block. If f returns true,
-// InspectInline invokes f recursively for each child of the block, followed by a call of f(nil).
-func InspectInline(inline Inline, f func(Inline) bool) {
- if !f(inline) {
- return
- }
- switch v := inline.(type) {
- case *InlineImage:
- for _, child := range v.Children {
- InspectInline(child, f)
- }
- case *InlineLink:
- for _, child := range v.Children {
- InspectInline(child, f)
- }
- case *ReferenceImage:
- for _, child := range v.Children {
- InspectInline(child, f)
- }
- case *ReferenceLink:
- for _, child := range v.Children {
- InspectInline(child, f)
- }
- }
- f(nil)
-}