~shulhan/asciidoctor-go

ref: v0.1.0 asciidoctor-go/document_title.go -rw-r--r-- 597 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
// 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 "fmt"

type DocumentTitle struct {
	Main string
	Sub  string
	el   *element
	raw  string
	sep  byte
}

//
// String return the combination of main and subtitle separated by colon or
// meta "title-separator" value.
//
func (docTitle *DocumentTitle) String() string {
	if len(docTitle.Sub) > 0 {
		return fmt.Sprintf("%s%c %s", docTitle.Main, docTitle.sep, docTitle.Sub)
	}
	return docTitle.Main
}