mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-09-10 21:12:30 +00:00
.github
bridge
contrib
docker
gateway
hook
img
internal
matterclient
matterhook
vendor
github.com
42wim
Baozisoftware
Benau
Jeffail
Philipp15b
Rhymen
SevereCloud
apex
av-elier
blang
d5
davecgh
dustin
dyatlov
francoispqt
fsnotify
go-asn1-ber
go-telegram-bot-api
golang
golang-jwt
gomarkdown
markdown
ast
html
parser
aside.go
attribute.go
block.go
block_table.go
callout.go
caption.go
citation.go
esc.go
figures.go
include.go
inline.go
matter.go
options.go
parser.go
ref.go
.gitignore
LICENSE.txt
README.md
changes-from-blackfriday.md
codecov.yml
doc.go
fuzz.go
markdown.go
todo.md
google
gopackage
gorilla
hashicorp
jpillora
json-iterator
kettek
keybase
klauspost
kyokomi
labstack
lrstanley
magiconair
matrix-org
matterbridge
mattermost
mattn
mgutz
minio
missdeer
mitchellh
modern-go
monaco-io
mreiferson
mrexodia
nelsonken
paulrosania
pborman
pelletier
philhofer
pkg
pmezard
rickb777
rivo
rs
russross
saintfish
shazow
sirupsen
sizeofint
skip2
slack-go
spf13
stretchr
subosito
technoweenie
tinylib
valyala
vincent-petithory
wiggin77
writeas
yaegashi
zfjagann
go.uber.org
golang.org
gomod.garykim.dev
google.golang.org
gopkg.in
layeh.com
modules.txt
version
.dockerignore
.fixmie.yml
.gitignore
.golangci.yaml
.goreleaser.yml
Dockerfile
LICENSE
README.md
changelog.md
go.mod
go.sum
matterbridge.go
matterbridge.toml.sample
matterbridge.toml.simple
tgs.Dockerfile
30 lines
546 B
Go
30 lines
546 B
Go
package parser
|
|
|
|
import (
|
|
"bytes"
|
|
"strconv"
|
|
)
|
|
|
|
// IsCallout detects a callout in the following format: <<N>> Where N is a integer > 0.
|
|
func IsCallout(data []byte) (id []byte, consumed int) {
|
|
if !bytes.HasPrefix(data, []byte("<<")) {
|
|
return nil, 0
|
|
}
|
|
start := 2
|
|
end := bytes.Index(data[start:], []byte(">>"))
|
|
if end < 0 {
|
|
return nil, 0
|
|
}
|
|
|
|
b := data[start : start+end]
|
|
b = bytes.TrimSpace(b)
|
|
i, err := strconv.Atoi(string(b))
|
|
if err != nil {
|
|
return nil, 0
|
|
}
|
|
if i <= 0 {
|
|
return nil, 0
|
|
}
|
|
return b, start + end + 2 // 2 for >>
|
|
}
|