1/* bibtex_create 2 Author: poo. 3 4 Copyright (C) 2018 poo 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19 05 jun 2018 20*/ 21 22 23:- module(bibtex_create, [ 24 bibtex_create/2, 25 bibtex_append/2 26 ]).
37entry_save(Stream, entry(Type, Keyword, Fields)) :-
38 format(Stream, '@~w{~w,\n', [Type, Keyword]),
39 fields_save(Stream, Fields),
40 write(Stream, '}\n').
47fields_save(_Stream, []). 48fields_save(Stream, [field(Name, Value)]) :- !, 49 format(Stream, ' ~w = {~w}', [Name, Value]). 50fields_save(Stream, [field(Name, Value)|Rest]) :- 51 format(Stream, ' ~w = {~w},\n', [Name, Value]), 52 fields_save(Stream, Rest).
62bibtex_create(File, Entries) :-
63 open(File, write, Stream),
64 maplist(entry_save(Stream), Entries),
65 close(Stream).
75bibtex_append(File, Entries) :-
76 open(File, append, Stream),
77 maplist(entry_save(Stream), Entries),
78 close(Stream)
bibtex_create: Predicates for creating a BibTeX file.
*/