~shulhan/asciidoctor-go

f4c31c2117be6e83c11b975163a7695eddba894b — Shulhan 3 months ago d2ff454
all: rename meta or metadata words to document attribute

The idea is to provide consistent naming for metadata and attribute.
The AsciiDoctor documentation mostly name them as document attribute.
9 files changed, 137 insertions(+), 136 deletions(-)

M README.md
M _doc/SPECS.adoc
M document.go
M document_attribute.go
M document_test.go
M element.go
M html_backend.go
M parser.go
M parser_test.go
M README.md => README.md +2 -2
@@ 115,7 115,7 @@ The numbered one is based on the old documentation.
* Open Blocks
* Predefined Attributes for Character Replacements

Supported metadata or attribute references,
Supported document attribute references,

* `author(_x)`
* `authorinitials(_x)`


@@ 141,7 141,7 @@ Supported metadata or attribute references,
* `version-label`


Additional metadata provides by this library,
Additional document attribute provides by this library,

* `author_names` - list of author full names separated by comma.


M _doc/SPECS.adoc => _doc/SPECS.adoc +2 -2
@@ 119,11 119,11 @@ DOC_REV_VERSION  = "v" 1*DIGIT "." 1*DIGIT "." 1*DIGIT
DOC_REV_DATE     = 1*2DIGIT 3*ALPHA 4*DIGIT
----

===  Metadata
===  Attributes

{url_ref}/document/metadata/[Reference^].

There are also metadata which affect how the document rendered,
There are also document attributes which affect how the document rendered,

----
DOC_ATTRIBUTE  = ":" DOC_ATTR_KEY ":" *LINE ("\" *LINE) LF

M document.go => document.go +48 -48
@@ 118,7 118,7 @@ func Open(file string) (doc *Document, err error) {
	doc = newDocument()
	doc.fpath = filepath.Join(wd, file)
	doc.file = file
	doc.Attributes[metaNameLastUpdateValue] = fi.ModTime().Round(time.Second).Format(`2006-01-02 15:04:05 Z0700`)
	doc.Attributes[docAttrLastUpdateValue] = fi.ModTime().Round(time.Second).Format(`2006-01-02 15:04:05 Z0700`)

	parse(doc, raw)



@@ 143,7 143,7 @@ func parse(doc *Document, content []byte) {
	docp.parseHeader()
	docp.doc.postParseHeader()

	sectLevel, ok = doc.Attributes[metaNameSectNumLevel]
	sectLevel, ok = doc.Attributes[docAttrSectNumLevel]
	if ok {
		doc.sectLevel, _ = strconv.Atoi(sectLevel)
	}


@@ 176,7 176,7 @@ func (doc *Document) ToHTMLEmbedded(out io.Writer) (err error) {
// ToHTML convert the Document object into full HTML document.
func (doc *Document) ToHTML(out io.Writer) (err error) {
	var (
		metaValue string
		docAttrValue string
	)

	doc.generateClasses()


@@ 186,24 186,24 @@ func (doc *Document) ToHTML(out io.Writer) (err error) {

	fmt.Fprint(buf, _htmlBegin)

	metaValue = doc.Attributes[MetaNameGenerator]
	if len(metaValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameGenerator, metaValue)
	docAttrValue = doc.Attributes[DocAttrGenerator]
	if len(docAttrValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", DocAttrGenerator, docAttrValue)
	}

	metaValue = doc.Attributes[MetaNameDescription]
	if len(metaValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameDescription, metaValue)
	docAttrValue = doc.Attributes[DocAttrDescription]
	if len(docAttrValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", DocAttrDescription, docAttrValue)
	}

	metaValue = doc.Attributes[MetaNameKeywords]
	if len(metaValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameKeywords, metaValue)
	docAttrValue = doc.Attributes[DocAttrKeywords]
	if len(docAttrValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", DocAttrKeywords, docAttrValue)
	}

	metaValue = doc.Attributes[MetaNameAuthorNames]
	if len(metaValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameAuthor, metaValue)
	docAttrValue = doc.Attributes[DocAttrAuthorNames]
	if len(docAttrValue) > 0 {
		fmt.Fprintf(buf, "\n<meta name=%q content=%q>", DocAttrAuthor, docAttrValue)
	}

	var title = doc.Title.String()


@@ 217,7 217,7 @@ func (doc *Document) ToHTML(out io.Writer) (err error) {
		isWithHeaderFooter = true
		ok                 bool
	)
	_, ok = doc.Attributes[metaNameNoHeaderFooter]
	_, ok = doc.Attributes[docAttrNoHeaderFooter]
	if ok {
		isWithHeaderFooter = false
	}


@@ 244,14 244,14 @@ func (doc *Document) ToHTMLBody(out io.Writer) (err error) {

func (doc *Document) generateClasses() {
	doc.classes.add(classNameArticle)
	doc.tocPosition, doc.tocIsEnabled = doc.Attributes[metaNameTOC]
	doc.tocPosition, doc.tocIsEnabled = doc.Attributes[docAttrTOC]

	switch doc.tocPosition {
	case metaValueLeft:
	case docAttrValueLeft:
		doc.classes.add(classNameToc2)
		doc.classes.add(classNameTocLeft)
		doc.tocClasses.add(classNameToc2)
	case metaValueRight:
	case docAttrValueRight:
		doc.classes.add(classNameToc2)
		doc.classes.add(classNameTocRight)
		doc.tocClasses.add(classNameToc2)


@@ 282,7 282,7 @@ func (doc *Document) toHTMLBody(buf *bytes.Buffer, withHeaderFooter bool) {
	)

	if withHeaderFooter {
		_, ok = doc.Attributes[metaNameNoHeader]
		_, ok = doc.Attributes[docAttrNoHeader]
		if !ok {
			htmlWriteHeader(doc, buf)
		}


@@ 293,7 293,7 @@ func (doc *Document) toHTMLBody(buf *bytes.Buffer, withHeaderFooter bool) {
	htmlWriteFootnoteDefs(doc, buf)

	if withHeaderFooter {
		_, ok = doc.Attributes[metaNameNoFooter]
		_, ok = doc.Attributes[docAttrNoFooter]
		if !ok {
			htmlWriteFooter(doc, buf)
		}


@@ 362,7 362,7 @@ func (doc *Document) tocHTML(out io.Writer) {
		ok bool
	)

	v, ok = doc.Attributes[metaNameTOCLevels]
	v, ok = doc.Attributes[docAttrTOCLevels]
	if ok {
		doc.TOCLevel, _ = strconv.Atoi(v)
		if doc.TOCLevel <= 0 {


@@ 370,7 370,7 @@ func (doc *Document) tocHTML(out io.Writer) {
		}
	}

	v, ok = doc.Attributes[metaNameTOCTitle]
	v, ok = doc.Attributes[docAttrTOCTitle]
	if ok && len(v) > 0 {
		doc.tocTitle = v
	}


@@ 395,11 395,11 @@ func (doc *Document) unpackRawAuthor() {
	)

	if len(doc.rawAuthors) == 0 {
		v = doc.Attributes[MetaNameAuthor]
		v = doc.Attributes[DocAttrAuthor]
		if len(v) > 0 {
			sb.WriteString(v)
		}
		v = doc.Attributes[metaNameEmail]
		v = doc.Attributes[docAttrEmail]
		if len(v) > 0 {
			sb.WriteString(` <`)
			sb.WriteString(v)


@@ 414,12 414,12 @@ func (doc *Document) unpackRawAuthor() {

	var (
		rawAuthors    = strings.Split(doc.rawAuthors, `;`)
		authorKey     = MetaNameAuthor
		emailKey      = metaNameEmail
		initialsKey   = metaNameAuthorInitials
		firstNameKey  = metaNameFirstName
		middleNameKey = metaNameMiddleName
		lastNameKey   = metaNameLastName
		authorKey     = DocAttrAuthor
		emailKey      = docAttrEmail
		initialsKey   = docAttrAuthorInitials
		firstNameKey  = docAttrFirstName
		middleNameKey = docAttrMiddleName
		lastNameKey   = docAttrLastName

		author    *Author
		rawAuthor string


@@ 453,12 453,12 @@ func (doc *Document) unpackRawAuthor() {
			// `author` and another is `author_1`.
		}

		authorKey = fmt.Sprintf(`%s_%d`, MetaNameAuthor, x+1)
		emailKey = fmt.Sprintf(`%s_%d`, metaNameEmail, x+1)
		initialsKey = fmt.Sprintf(`%s_%d`, metaNameAuthorInitials, x+1)
		firstNameKey = fmt.Sprintf(`%s_%d`, metaNameFirstName, x+1)
		middleNameKey = fmt.Sprintf(`%s_%d`, metaNameMiddleName, x+1)
		lastNameKey = fmt.Sprintf(`%s_%d`, metaNameLastName, x+1)
		authorKey = fmt.Sprintf(`%s_%d`, DocAttrAuthor, x+1)
		emailKey = fmt.Sprintf(`%s_%d`, docAttrEmail, x+1)
		initialsKey = fmt.Sprintf(`%s_%d`, docAttrAuthorInitials, x+1)
		firstNameKey = fmt.Sprintf(`%s_%d`, docAttrFirstName, x+1)
		middleNameKey = fmt.Sprintf(`%s_%d`, docAttrMiddleName, x+1)
		lastNameKey = fmt.Sprintf(`%s_%d`, docAttrLastName, x+1)

		doc.Attributes[authorKey] = author.FullName()
		doc.Attributes[emailKey] = author.Email


@@ 470,21 470,21 @@ func (doc *Document) unpackRawAuthor() {

	v = sb.String()
	if len(v) > 0 {
		doc.Attributes[MetaNameAuthorNames] = v
		doc.Attributes[DocAttrAuthorNames] = v
	}
}

func (doc *Document) unpackRawRevision() {
	if len(doc.rawRevision) > 0 {
		doc.Revision = parseRevision(doc.rawRevision)
		doc.Attributes[metaNameRevNumber] = doc.Revision.Number
		doc.Attributes[metaNameRevDate] = doc.Revision.Date
		doc.Attributes[metaNameRevRemark] = doc.Revision.Remark
		doc.Attributes[docAttrRevNumber] = doc.Revision.Number
		doc.Attributes[docAttrRevDate] = doc.Revision.Date
		doc.Attributes[docAttrRevRemark] = doc.Revision.Remark
		return
	}
	doc.Revision.Number = doc.Attributes[metaNameRevNumber]
	doc.Revision.Date = doc.Attributes[metaNameRevDate]
	doc.Revision.Remark = doc.Attributes[metaNameRevRemark]
	doc.Revision.Number = doc.Attributes[docAttrRevNumber]
	doc.Revision.Date = doc.Attributes[docAttrRevDate]
	doc.Revision.Remark = doc.Attributes[docAttrRevRemark]
}

func (doc *Document) unpackRawTitle() {


@@ 495,9 495,9 @@ func (doc *Document) unpackRawTitle() {
	)

	if len(doc.Title.raw) == 0 {
		doc.Title.raw = doc.Attributes[metaNameDocTitle]
		doc.Title.raw = doc.Attributes[docAttrDocTitle]
		if len(doc.Title.raw) == 0 {
			doc.Title.raw = doc.Attributes[metaNameTitle]
			doc.Title.raw = doc.Attributes[docAttrTitle]
			if len(doc.Title.raw) == 0 {
				return
			}


@@ 506,7 506,7 @@ func (doc *Document) unpackRawTitle() {

	doc.Title.el = parseInlineMarkup(doc, []byte(doc.Title.raw))
	title = doc.Title.el.toText()
	doc.Attributes[metaNameDocTitle] = title
	doc.Attributes[docAttrDocTitle] = title

	for x = len(title) - 1; x > 0; x-- {
		if title[x] == doc.Title.sep {


@@ 531,7 531,7 @@ func (doc *Document) unpackTitleSeparator() {
		ok bool
	)

	v, ok = doc.Attributes[metaNameTitleSeparator]
	v, ok = doc.Attributes[docAttrTitleSeparator]
	if ok {
		v = strings.TrimSpace(v)
		if len(v) > 0 {

M document_attribute.go => document_attribute.go +56 -7
@@ 5,19 5,68 @@ package asciidoctor

import "strings"

// List of document attribute.
const (
	DocAttrAuthor      = `author`       // May contain the first author full name only.
	DocAttrAuthorNames = `author_names` // List of author full names, separated by comma.
	DocAttrDescription = `description`
	DocAttrGenerator   = `generator`
	DocAttrKeywords    = `keywords`

	docAttrAuthorInitials  = `authorinitials`
	docAttrDocTitle        = `doctitle`
	docAttrEmail           = attrValueEmail
	docAttrFirstName       = `firstname`
	docAttrIDPrefix        = `idprefix`
	docAttrIDSeparator     = `idseparator`
	docAttrLastName        = `lastname`
	docAttrLastUpdateLabel = `last-update-label`
	docAttrLastUpdateValue = `last-update-value`
	docAttrMiddleName      = `middlename`
	docAttrNoFooter        = `nofooter`
	docAttrNoHeader        = `noheader`
	docAttrNoHeaderFooter  = `no-header-footer`
	docAttrNoTitle         = `notitle`
	docAttrRevDate         = `revdate`
	docAttrRevNumber       = `revnumber`
	docAttrRevRemark       = `revremark`
	docAttrSectAnchors     = `sectanchors`
	docAttrSectIDs         = `sectids`
	docAttrSectLinks       = `sectlinks`
	docAttrSectNumLevel    = `sectnumlevels`
	docAttrSectNums        = `sectnums`
	docAttrShowTitle       = `showtitle`
	docAttrTOC             = `toc`
	docAttrTOCLevels       = `toclevels`
	docAttrTOCTitle        = `toc-title`
	docAttrTableCaption    = `table-caption`
	docAttrTitle           = attrNameTitle
	docAttrTitleSeparator  = `title-separator`
	docAttrVersionLabel    = `version-label`
)

// List of possible document attribute value.
const (
	docAttrValueAuto     = `auto`
	docAttrValueMacro    = `macro`
	docAttrValuePreamble = `preamble`
	docAttrValueLeft     = `left`
	docAttrValueRight    = `right`
)

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

func newDocumentAttribute() DocumentAttribute {
	return DocumentAttribute{
		MetaNameGenerator:       `asciidoctor-go ` + Version,
		metaNameLastUpdateLabel: `Last updated`,
		metaNameLastUpdateValue: ``,
		metaNameSectIDs:         ``,
		metaNameShowTitle:       ``,
		metaNameTableCaption:    ``,
		metaNameVersionLabel:    ``,
		DocAttrGenerator:       `asciidoctor-go ` + Version,
		docAttrLastUpdateLabel: `Last updated`,
		docAttrLastUpdateValue: ``,
		docAttrSectIDs:         ``,
		docAttrShowTitle:       ``,
		docAttrTableCaption:    ``,
		docAttrVersionLabel:    ``,
	}
}


M document_test.go => document_test.go +1 -1
@@ 24,7 24,7 @@ func TestOpen(t *testing.T) {

	// Since we cannot overwrite the asciidoctor output for
	// generator, we override ourself.
	doc.Attributes[MetaNameGenerator] = `Asciidoctor 2.0.18`
	doc.Attributes[DocAttrGenerator] = `Asciidoctor 2.0.18`

	fout, err = os.OpenFile(`testdata/test.got.html`, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
	if err != nil {

M element.go => element.go +3 -3
@@ 578,7 578,7 @@ func (el *element) parseSection(doc *Document, isDiscrete bool) {
	el.Text = container.toText()

	if len(el.ID) == 0 {
		_, ok = doc.Attributes[metaNameSectIDs]
		_, ok = doc.Attributes[docAttrSectIDs]
		if ok {
			el.ID = generateID(doc, el.Text)
			el.ID = doc.registerAnchor(el.ID, el.Text)


@@ 596,7 596,7 @@ func (el *element) parseSection(doc *Document, isDiscrete bool) {
	}
	doc.titleID[el.Text] = el.ID

	_, ok = doc.Attributes[metaNameSectNums]
	_, ok = doc.Attributes[docAttrSectNums]
	if ok && !isDiscrete {
		el.sectnums = doc.sectnums.set(el.level)
	}


@@ 838,7 838,7 @@ func (el *element) toHTML(doc *Document, w io.Writer) {
		htmlWriteFootnote(el, w)

	case elKindMacroTOC:
		if doc.tocIsEnabled && doc.tocPosition == metaValueMacro {
		if doc.tocIsEnabled && doc.tocPosition == docAttrValueMacro {
			doc.tocHTML(w)
		}


M html_backend.go => html_backend.go +14 -14
@@ 878,7 878,7 @@ func htmlWriteBody(doc *Document, out *bytes.Buffer) {
			}

			fmt.Fprint(out, _lf+`</div>`)
			if doc.tocIsEnabled && doc.tocPosition == metaValuePreamble {
			if doc.tocIsEnabled && doc.tocPosition == docAttrValuePreamble {
				doc.tocHTML(out)
			}
			fmt.Fprint(out, _lf+`</div>`)


@@ 909,7 909,7 @@ func htmlWriteFooter(doc *Document, out io.Writer) {
<div id="footer-text">`)

	if len(doc.Revision.Number) > 0 {
		label, ok = doc.Attributes[metaNameVersionLabel]
		label, ok = doc.Attributes[docAttrVersionLabel]
		if ok && len(label) == 0 {
			label = `Version `
		} else {


@@ 919,9 919,9 @@ func htmlWriteFooter(doc *Document, out io.Writer) {
		fmt.Fprintf(out, "\n%s%s<br>", label, doc.Revision.Number)
	}

	label, ok = doc.Attributes[metaNameLastUpdateLabel]
	label, ok = doc.Attributes[docAttrLastUpdateLabel]
	if ok {
		value = doc.Attributes[metaNameLastUpdateValue]
		value = doc.Attributes[docAttrLastUpdateValue]
		if len(value) != 0 {
			fmt.Fprintf(out, "\n%s %s", label, value)
		}


@@ 992,9 992,9 @@ func htmlWriteHeader(doc *Document, out io.Writer) {
		ok     bool
	)

	_, ok = doc.Attributes[metaNameShowTitle]
	_, ok = doc.Attributes[docAttrShowTitle]
	if ok {
		_, ok = doc.Attributes[metaNameNoTitle]
		_, ok = doc.Attributes[docAttrNoTitle]
		if !ok && doc.Title.el != nil {
			fmt.Fprint(out, "\n<h1>")
			doc.Title.el.toHTML(doc, out)


@@ 1027,7 1027,7 @@ func htmlWriteHeader(doc *Document, out io.Writer) {
	}

	if len(doc.Revision.Number) > 0 {
		prefix, ok = doc.Attributes[metaNameVersionLabel]
		prefix, ok = doc.Attributes[docAttrVersionLabel]
		if ok && len(prefix) == 0 {
			prefix = defVersionPrefix
		} else {


@@ 1048,16 1048,16 @@ func htmlWriteHeader(doc *Document, out io.Writer) {
	}
	if len(doc.Revision.Remark) > 0 {
		fmt.Fprintf(out, "\n<br><span id=%q>%s</span>",
			metaNameRevRemark, doc.Revision.Remark)
			docAttrRevRemark, doc.Revision.Remark)
	}
	if haveHeader {
		fmt.Fprint(out, "\n</div>")
	}

	if doc.tocIsEnabled && (doc.tocPosition == `` ||
		doc.tocPosition == metaValueAuto ||
		doc.tocPosition == metaValueLeft ||
		doc.tocPosition == metaValueRight) {
		doc.tocPosition == docAttrValueAuto ||
		doc.tocPosition == docAttrValueLeft ||
		doc.tocPosition == docAttrValueRight) {
		doc.tocHTML(out)
	}
	fmt.Fprint(out, "\n</div>")


@@ 1206,11 1206,11 @@ func htmlWriteSection(doc *Document, el *element, out io.Writer) {
		withSectlinks   bool
	)

	_, withSectAnchors = doc.Attributes[metaNameSectAnchors]
	_, withSectAnchors = doc.Attributes[docAttrSectAnchors]
	if withSectAnchors {
		fmt.Fprintf(out, `<a class="anchor" href="#%s"></a>`, el.ID)
	}
	_, withSectlinks = doc.Attributes[metaNameSectLinks]
	_, withSectlinks = doc.Attributes[docAttrSectLinks]
	if withSectlinks {
		fmt.Fprintf(out, `<a class="link" href="#%s">`, el.ID)
	}


@@ 1283,7 1283,7 @@ func htmlWriteTable(doc *Document, el *element, out io.Writer) {
		)

		doc.counterTable++
		_, withTableCaption = doc.Attributes[metaNameTableCaption]
		_, withTableCaption = doc.Attributes[docAttrTableCaption]

		if withTableCaption {
			caption, ok = el.Attrs[attrNameCaption]

M parser.go => parser.go +6 -54
@@ 171,55 171,6 @@ const (
	classNameUpperroman   = `upperroman`
)

// List of document metadata.
const (
	MetaNameAuthor      = `author`       // May contain the first author full name only.
	MetaNameAuthorNames = `author_names` // List of author full names, separated by comma.
	MetaNameDescription = `description`
	MetaNameGenerator   = `generator`
	MetaNameKeywords    = `keywords`

	metaNameAuthorInitials  = `authorinitials`
	metaNameDocTitle        = `doctitle`
	metaNameEmail           = attrValueEmail
	metaNameFirstName       = `firstname`
	metaNameIDPrefix        = `idprefix`
	metaNameIDSeparator     = `idseparator`
	metaNameLastName        = `lastname`
	metaNameLastUpdateLabel = `last-update-label`
	metaNameLastUpdateValue = `last-update-value`
	metaNameMiddleName      = `middlename`
	metaNameNoFooter        = `nofooter`
	metaNameNoHeader        = `noheader`
	metaNameNoHeaderFooter  = `no-header-footer`
	metaNameNoTitle         = `notitle`
	metaNameRevDate         = `revdate`
	metaNameRevNumber       = `revnumber`
	metaNameRevRemark       = `revremark`
	metaNameSectAnchors     = `sectanchors`
	metaNameSectIDs         = `sectids`
	metaNameSectLinks       = `sectlinks`
	metaNameSectNumLevel    = `sectnumlevels`
	metaNameSectNums        = `sectnums`
	metaNameShowTitle       = `showtitle`
	metaNameTOC             = `toc`
	metaNameTOCLevels       = `toclevels`
	metaNameTOCTitle        = `toc-title`
	metaNameTableCaption    = `table-caption`
	metaNameTitle           = attrNameTitle
	metaNameTitleSeparator  = `title-separator`
	metaNameVersionLabel    = `version-label`
)

// List of possible metadata value.
const (
	metaValueAuto     = `auto`
	metaValueMacro    = `macro`
	metaValuePreamble = `preamble`
	metaValueLeft     = `left`
	metaValueRight    = `right`
)

const (
	optNameAutoplay               = `autoplay`
	optNameAutowidth              = `autowidth`


@@ 406,8 357,8 @@ func applySubstitutions(doc *Document, content []byte) []byte {
// generateID generate ID for anchor.
// This function follow the [Mozilla specification].
//
// The generated ID is affected by the following metadata: `idprefix` and
// `idseparator`.
// The generated ID is affected by the following document attributes:
// `idprefix` and `idseparator`.
//
// The idprefix must be ASCII string.
// It must start with '_', '-', or ASCII letters, otherwise the '_' will be


@@ 429,7 380,7 @@ func generateID(doc *Document, str string) string {
		ok   bool
	)

	v, ok = doc.Attributes[metaNameIDPrefix]
	v, ok = doc.Attributes[docAttrIDPrefix]
	if ok {
		v = strings.TrimSpace(v)
		if len(v) > 0 {


@@ 439,11 390,12 @@ func generateID(doc *Document, str string) string {

	bout = make([]byte, 0, len(str))

	v, ok = doc.Attributes[metaNameIDSeparator]
	v, ok = doc.Attributes[docAttrIDSeparator]
	if ok {
		v = strings.TrimSpace(v)
		if len(v) == 0 {
			// idseparator metadata exist and set to empty.
			// idseparator document attribute exist and set to
			// empty.
			idSep = 0
		} else {
			c = v[0]

M parser_test.go => parser_test.go +5 -5
@@ 29,7 29,7 @@ func TestGenerateID(t *testing.T) {
		desc: `With idprefix`,
		doc: &Document{
			Attributes: DocumentAttribute{
				metaNameIDPrefix: `123`,
				docAttrIDPrefix: `123`,
			},
		},
		inputExp: map[string]string{


@@ 40,7 40,7 @@ func TestGenerateID(t *testing.T) {
		desc: `With empty idseparator`,
		doc: &Document{
			Attributes: DocumentAttribute{
				metaNameIDSeparator: ``,
				docAttrIDSeparator: ``,
			},
		},
		inputExp: map[string]string{


@@ 51,7 51,7 @@ func TestGenerateID(t *testing.T) {
		desc: `With idseparator`,
		doc: &Document{
			Attributes: DocumentAttribute{
				metaNameIDSeparator: `-`,
				docAttrIDSeparator: `-`,
			},
		},
		inputExp: map[string]string{


@@ 62,8 62,8 @@ func TestGenerateID(t *testing.T) {
		desc: `With idprefix and idseparator`,
		doc: &Document{
			Attributes: DocumentAttribute{
				metaNameIDPrefix:    `id_`,
				metaNameIDSeparator: `-`,
				docAttrIDPrefix:    `id_`,
				docAttrIDSeparator: `-`,
			},
		},
		inputExp: map[string]string{