String returns a BibTex data structure as a simplified BibTex string.
()
| 169 | |
| 170 | // String returns a BibTex data structure as a simplified BibTex string. |
| 171 | func (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. |
| 189 | func (bib *BibTex) RawString() string { |
nothing calls this directly
no test coverage detected