@@ -169,6 +169,106 @@ def test_display_order(self):
169169 title = {Optical fiber fusion slicing},
170170 author = {Yablon, A.D.}
171171}
172+ """
173+ self .assertEqual (result , expected )
174+
175+ def test_align_multiline_values (self ):
176+ with open ('bibtexparser/tests/data/article_multilines.bib' ) as bibtex_file :
177+ bib_database = bibtexparser .load (bibtex_file )
178+ writer = BibTexWriter ()
179+ writer .align_multiline_values = True
180+ writer .display_order = ["author" , "title" , "year" , "journal" , "abstract" , "comments" , "keyword" ]
181+ result = bibtexparser .dumps (bib_database , writer )
182+ expected = \
183+ """@article{Cesar2013,
184+ author = {Jean César},
185+ title = {A mutline line title is very amazing. It should be
186+ long enough to test multilines... with two lines or should we
187+ even test three lines... What an amazing title.},
188+ year = {2013},
189+ journal = {Nice Journal},
190+ abstract = {This is an abstract. This line should be long enough to test
191+ multilines... and with a french érudit word},
192+ comments = {A comment},
193+ keyword = {keyword1, keyword2,
194+ multiline-keyword1, multiline-keyword2}
195+ }
196+ """
197+ self .assertEqual (result , expected )
198+
199+ def test_align_multiline_values_with_align (self ):
200+ with open ('bibtexparser/tests/data/article_multilines.bib' ) as bibtex_file :
201+ bib_database = bibtexparser .load (bibtex_file )
202+ writer = BibTexWriter ()
203+ writer .align_multiline_values = True
204+ writer .align_values = True
205+ writer .display_order = ["author" , "title" , "year" , "journal" , "abstract" , "comments" , "keyword" ]
206+ result = bibtexparser .dumps (bib_database , writer )
207+ expected = \
208+ """@article{Cesar2013,
209+ author = {Jean César},
210+ title = {A mutline line title is very amazing. It should be
211+ long enough to test multilines... with two lines or should we
212+ even test three lines... What an amazing title.},
213+ year = {2013},
214+ journal = {Nice Journal},
215+ abstract = {This is an abstract. This line should be long enough to test
216+ multilines... and with a french érudit word},
217+ comments = {A comment},
218+ keyword = {keyword1, keyword2,
219+ multiline-keyword1, multiline-keyword2}
220+ }
221+ """
222+ self .assertEqual (result , expected )
223+
224+ def test_align_multiline_values_with_indent (self ):
225+ with open ('bibtexparser/tests/data/article_multilines.bib' ) as bibtex_file :
226+ bib_database = bibtexparser .load (bibtex_file )
227+ writer = BibTexWriter ()
228+ writer .align_multiline_values = True
229+ writer .indent = ' ' * 3
230+ writer .display_order = ["author" , "title" , "year" , "journal" , "abstract" , "comments" , "keyword" ]
231+ result = bibtexparser .dumps (bib_database , writer )
232+ expected = \
233+ """@article{Cesar2013,
234+ author = {Jean César},
235+ title = {A mutline line title is very amazing. It should be
236+ long enough to test multilines... with two lines or should we
237+ even test three lines... What an amazing title.},
238+ year = {2013},
239+ journal = {Nice Journal},
240+ abstract = {This is an abstract. This line should be long enough to test
241+ multilines... and with a french érudit word},
242+ comments = {A comment},
243+ keyword = {keyword1, keyword2,
244+ multiline-keyword1, multiline-keyword2}
245+ }
246+ """
247+ self .assertEqual (result , expected )
248+
249+ def test_align_multiline_values_with_align_with_indent (self ):
250+ with open ('bibtexparser/tests/data/article_multilines.bib' ) as bibtex_file :
251+ bib_database = bibtexparser .load (bibtex_file )
252+ writer = BibTexWriter ()
253+ writer .align_multiline_values = True
254+ writer .indent = ' ' * 3
255+ writer .align_values = True
256+ writer .display_order = ["author" , "title" , "year" , "journal" , "abstract" , "comments" , "keyword" ]
257+ result = bibtexparser .dumps (bib_database , writer )
258+ expected = \
259+ """@article{Cesar2013,
260+ author = {Jean César},
261+ title = {A mutline line title is very amazing. It should be
262+ long enough to test multilines... with two lines or should we
263+ even test three lines... What an amazing title.},
264+ year = {2013},
265+ journal = {Nice Journal},
266+ abstract = {This is an abstract. This line should be long enough to test
267+ multilines... and with a french érudit word},
268+ comments = {A comment},
269+ keyword = {keyword1, keyword2,
270+ multiline-keyword1, multiline-keyword2}
271+ }
172272"""
173273 self .assertEqual (result , expected )
174274
0 commit comments