~shulhan/asciidoctor-go

ref: v0.1.0 asciidoctor-go/attribute_entry.go -rw-r--r-- 784 bytes
4c1ded16Shulhan Release asciidoctor-go v0.1.0 (2021-03-06) 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package asciidoctor

import "strings"

//
// AttributeEntry contains the mapping of global attribute keys in the headers
// with its value.
//
type AttributeEntry map[string]string

func newAttributeEntry() AttributeEntry {
	return AttributeEntry{
		metaNameSectIDs:      "",
		metaNameShowTitle:    "",
		metaNameTableCaption: "",
		metaNameVersionLabel: "",
	}
}

func (entry *AttributeEntry) apply(key, val string) {
	if key[0] == '!' {
		delete(*entry, strings.TrimSpace(key[1:]))
	} else if key[len(key)-1] == '!' {
		delete(*entry, strings.TrimSpace(key[:len(key)-1]))
	} else {
		(*entry)[key] = val
	}
}