MCPcopy Create free account
hub / github.com/cogentcore/core / String

Method String

parse/languages/bibtex/bibtex.go:171–186  ·  view source on GitHub ↗

String returns a BibTex data structure as a simplified BibTex string.

()

Source from the content-addressed store, hash-verified

169
170// String returns a BibTex data structure as a simplified BibTex string.
171func (bib *BibTex) String() string {
172 var bibtex bytes.Buffer
173 for _, entry := range bib.Entries {
174 bibtex.WriteString(fmt.Sprintf("@%s{%s,\n", entry.Type, entry.CiteName))
175 for key, val := range entry.Fields {
176 if i, err := strconv.Atoi(strings.TrimSpace(val.String())); err == nil {
177 bibtex.WriteString(fmt.Sprintf(" %s = %d,\n", key, i))
178 } else {
179 bibtex.WriteString(fmt.Sprintf(" %s = {%s},\n", key, strings.TrimSpace(val.String())))
180 }
181 }
182 bibtex.Truncate(bibtex.Len() - 2)
183 bibtex.WriteString(fmt.Sprintf("\n}\n"))
184 }
185 return bibtex.String()
186}
187
188// RawString returns a BibTex data structure in its internal representation.
189func (bib *BibTex) RawString() string {

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
WriteStringMethod · 0.80
StringMethod · 0.65
LenMethod · 0.65
TruncateMethod · 0.45

Tested by

no test coverage detected