aboutsummaryrefslogtreecommitdiff
path: root/parser.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-12-19 22:52:09 +0700
committerShulhan <ms@kilabit.info>2022-12-19 22:53:42 +0700
commitd9582373ece2f5da42725e22bb90c5daa93316df (patch)
treefd4142cb88d8e9466b6d82a3d8591e2e0c0765dc /parser.go
parent56de5ca1d10d422ad33a550bdb4e358130a7ff3c (diff)
downloadasciidoctor-go-d9582373ece2f5da42725e22bb90c5daa93316df.tar.xz
all: support multi line attribute values
If the attribute value end with backslash '\', the value continue to the next line.
Diffstat (limited to 'parser.go')
-rw-r--r--parser.go46
1 files changed, 0 insertions, 46 deletions
diff --git a/parser.go b/parser.go
index fe6e0ff..1eb53c4 100644
--- a/parser.go
+++ b/parser.go
@@ -553,52 +553,6 @@ func isValidID(id []byte) bool {
return true
}
-// parseAttribute parse document attribute and return its key and optional
-// value.
-//
-// DOC_ATTRIBUTE = ":" DOC_ATTR_KEY ":" *STRING LF
-//
-// DOC_ATTR_KEY = ( "toc" / "sectanchors" / "sectlinks"
-// / "imagesdir" / "data-uri" / *META_KEY ) LF
-//
-// META_KEY_CHAR = (A..Z | a..z | 0..9 | '_')
-//
-// META_KEY = 1META_KEY_CHAR *(META_KEY_CHAR | '-')
-func parseAttribute(line []byte, strict bool) (key, value string, ok bool) {
- var (
- sb strings.Builder
- valb []byte
- x int
- )
-
- if !(ascii.IsAlnum(line[1]) || line[1] == '_') {
- return ``, ``, false
- }
-
- sb.WriteByte(line[1])
- x = 2
- for ; x < len(line); x++ {
- if line[x] == ':' {
- break
- }
- if ascii.IsAlnum(line[x]) || line[x] == '_' ||
- line[x] == '-' || line[x] == '!' {
- sb.WriteByte(line[x])
- continue
- }
- if strict {
- return ``, ``, false
- }
- }
- if x == len(line) {
- return ``, ``, false
- }
-
- valb = bytes.TrimSpace(line[x+1:])
-
- return sb.String(), string(valb), true
-}
-
// parseAttrRef parse the attribute reference, an attribute key wrapped by
// "{" "}". If the attribute reference exist, replace the content with the
// attribute value and reset the parser state to zero.