Loading pybtex/backends/html.py +6 −5 Original line number Diff line number Diff line Loading @@ -27,13 +27,13 @@ HTML output backend. >>> from pybtex.richtext import Tag, HRef >>> html = Backend() >>> print Tag('em', '').render(html) >>> print(Tag('em', '').render(html)) <BLANKLINE> >>> print Tag('em', 'Hard &', ' heavy').render(html) >>> print(Tag('em', 'Hard &', ' heavy').render(html)) <em>Hard & heavy</em> >>> print HRef('/', '').render(html) >>> print(HRef('/', '').render(html)) <BLANKLINE> >>> print HRef('/', 'Hard & heavy').render(html) >>> print(HRef('/', 'Hard & heavy').render(html)) <a href="/">Hard & heavy</a> """ from __future__ import unicode_literals Loading @@ -57,7 +57,7 @@ PROLOGUE = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> class Backend(BaseBackend): u""" >>> from pybtex.richtext import Text, Tag, Symbol >>> print Tag('em', Text(u'Л.:', Symbol('nbsp'), u'<<Химия>>')).render(Backend()) >>> print(Tag('em', Text(u'Л.:', Symbol('nbsp'), u'<<Химия>>')).render(Backend())) <em>Л.: <<Химия>></em> """ Loading Loading @@ -91,3 +91,4 @@ class Backend(BaseBackend): def write_entry(self, key, label, text): self.output(u'<dt>%s</dt>\n' % label) self.output(u'<dd>%s</dd>\n' % text) pybtex/backends/latex.py +7 −6 Original line number Diff line number Diff line Loading @@ -25,15 +25,15 @@ LaTeX output backend. >>> from pybtex.richtext import Tag, HRef >>> latex = Backend() >>> print Tag('em', '').render(latex) >>> print(Tag('em', '').render(latex)) <BLANKLINE> >>> print Tag('em', 'Non-', 'empty').render(latex) >>> print(Tag('em', 'Non-', 'empty').render(latex)) \\emph{Non-empty} >>> print HRef('/', '').render(latex) >>> print(HRef('/', '').render(latex)) <BLANKLINE> >>> print HRef('/', 'Non-', 'empty').render(latex) >>> print(HRef('/', 'Non-', 'empty').render(latex)) \\href{/}{Non-empty} >>> print HRef('http://example.org/', 'http://example.org/').render(latex) >>> print(HRef('http://example.org/', 'http://example.org/').render(latex)) \\url{http://example.org/} """ from __future__ import unicode_literals Loading Loading @@ -86,7 +86,7 @@ class Backend(BaseBackend): def format_protected(self, text): """ >>> from pybtex.richtext import Protected >>> print Protected('CTAN').render_as('latex') >>> print(Protected('CTAN').render_as('latex')) {CTAN} """ Loading @@ -105,3 +105,4 @@ class Backend(BaseBackend): def write_entry(self, key, label, text): self.output(u'\n\n\\bibitem[%s]{%s}\n' % (label, key)) self.output(text) pybtex/backends/markdown.py +5 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ Markdown output backend. >>> from pybtex.richtext import Tag, HRef >>> markdown = Backend() >>> print Tag('em', '').render(markdown) >>> print(Tag('em', '').render(markdown)) <BLANKLINE> >>> print Tag('em', 'Non-', 'empty').render(markdown) >>> print(Tag('em', 'Non-', 'empty').render(markdown)) *Non\-empty* >>> print HRef('/', '').render(markdown) >>> print(HRef('/', '').render(markdown)) <BLANKLINE> >>> print HRef('/', 'Non-', 'empty').render(markdown) >>> print(HRef('/', 'Non-', 'empty').render(markdown)) [Non\-empty](/) """ from __future__ import unicode_literals Loading Loading @@ -123,3 +123,4 @@ class Backend(BaseBackend): else: self.output(u'[%s] ' % label) self.output(u'%s \n' % text) pybtex/bibtex/bst.py +8 −7 Original line number Diff line number Diff line Loading @@ -49,19 +49,19 @@ quote_or_comment = re.compile(r'[%"]') def strip_comment(line): """Strip the commented part of the line." >>> print strip_comment('a normal line') >>> print(strip_comment('a normal line')) a normal line >>> print strip_comment('%') >>> print(strip_comment('%')) <BLANKLINE> >>> print strip_comment('%comment') >>> print(strip_comment('%comment')) <BLANKLINE> >>> print strip_comment('trailing%') >>> print(strip_comment('trailing%')) trailing >>> print strip_comment('a normal line% and a comment') >>> print(strip_comment('a normal line% and a comment')) a normal line >>> print strip_comment('"100% compatibility" is a myth') >>> print(strip_comment('"100% compatibility" is a myth')) "100% compatibility" is a myth >>> print strip_comment('"100% compatibility" is a myth% or not?') >>> print(strip_comment('"100% compatibility" is a myth% or not?')) "100% compatibility" is a myth """ Loading Loading @@ -165,3 +165,4 @@ if __name__ == '__main__': import sys from pprint import pprint pprint(parse_file(sys.argv[1])) pybtex/bibtex/names.py +10 −9 Original line number Diff line number Diff line Loading @@ -22,23 +22,23 @@ """BibTeX-like name formatting. >>> name = 'Charles Louis Xavier Joseph de la Vallee Poussin' >>> print format_name(name, '{vv~}{ll}{, jj}{, f.}') >>> print(format_name(name, '{vv~}{ll}{, jj}{, f.}')) de~la Vallee~Poussin, C.~L. X.~J. >>> name = 'abc' >>> print format_name(name, '{vv~}{ll}{, jj}{, f.}') >>> print(format_name(name, '{vv~}{ll}{, jj}{, f.}')) abc >>> name = 'Jean-Pierre Hansen' >>> print format_name(name, '{ff~}{vv~}{ll}{, jj}') >>> print(format_name(name, '{ff~}{vv~}{ll}{, jj}')) Jean-Pierre Hansen >>> print format_name(name, '{f.~}{vv~}{ll}{, jj}') >>> print(format_name(name, '{f.~}{vv~}{ll}{, jj}')) J.-P. Hansen >>> name = 'F. Phidias Phony-Baloney' >>> print format_name(name, '{v{}}{l}') >>> print(format_name(name, '{v{}}{l}')) P.-B >>> print format_name(name, '{v{}}{l.}') >>> print(format_name(name, '{v{}}{l.}')) P.-B. >>> print format_name(name, '{v{}}{l{}}') >>> print(format_name(name, '{v{}}{l{}}')) PB """ from __future__ import unicode_literals Loading Loading @@ -260,9 +260,9 @@ def join(words, tie='~', space=' '): Otherwise space is inserted. Should produce the same oubput as BibTeX. >>> print join(['a', 'long', 'long', 'road']) >>> print(join(['a', 'long', 'long', 'road'])) a~long long~road >>> print join(['very', 'long', 'phrase']) >>> print(join(['very', 'long', 'phrase'])) very long~phrase """ Loading Loading @@ -365,3 +365,4 @@ class NameFormatParser(Scanner): def eat_whitespace(self): pass Loading
pybtex/backends/html.py +6 −5 Original line number Diff line number Diff line Loading @@ -27,13 +27,13 @@ HTML output backend. >>> from pybtex.richtext import Tag, HRef >>> html = Backend() >>> print Tag('em', '').render(html) >>> print(Tag('em', '').render(html)) <BLANKLINE> >>> print Tag('em', 'Hard &', ' heavy').render(html) >>> print(Tag('em', 'Hard &', ' heavy').render(html)) <em>Hard & heavy</em> >>> print HRef('/', '').render(html) >>> print(HRef('/', '').render(html)) <BLANKLINE> >>> print HRef('/', 'Hard & heavy').render(html) >>> print(HRef('/', 'Hard & heavy').render(html)) <a href="/">Hard & heavy</a> """ from __future__ import unicode_literals Loading @@ -57,7 +57,7 @@ PROLOGUE = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> class Backend(BaseBackend): u""" >>> from pybtex.richtext import Text, Tag, Symbol >>> print Tag('em', Text(u'Л.:', Symbol('nbsp'), u'<<Химия>>')).render(Backend()) >>> print(Tag('em', Text(u'Л.:', Symbol('nbsp'), u'<<Химия>>')).render(Backend())) <em>Л.: <<Химия>></em> """ Loading Loading @@ -91,3 +91,4 @@ class Backend(BaseBackend): def write_entry(self, key, label, text): self.output(u'<dt>%s</dt>\n' % label) self.output(u'<dd>%s</dd>\n' % text)
pybtex/backends/latex.py +7 −6 Original line number Diff line number Diff line Loading @@ -25,15 +25,15 @@ LaTeX output backend. >>> from pybtex.richtext import Tag, HRef >>> latex = Backend() >>> print Tag('em', '').render(latex) >>> print(Tag('em', '').render(latex)) <BLANKLINE> >>> print Tag('em', 'Non-', 'empty').render(latex) >>> print(Tag('em', 'Non-', 'empty').render(latex)) \\emph{Non-empty} >>> print HRef('/', '').render(latex) >>> print(HRef('/', '').render(latex)) <BLANKLINE> >>> print HRef('/', 'Non-', 'empty').render(latex) >>> print(HRef('/', 'Non-', 'empty').render(latex)) \\href{/}{Non-empty} >>> print HRef('http://example.org/', 'http://example.org/').render(latex) >>> print(HRef('http://example.org/', 'http://example.org/').render(latex)) \\url{http://example.org/} """ from __future__ import unicode_literals Loading Loading @@ -86,7 +86,7 @@ class Backend(BaseBackend): def format_protected(self, text): """ >>> from pybtex.richtext import Protected >>> print Protected('CTAN').render_as('latex') >>> print(Protected('CTAN').render_as('latex')) {CTAN} """ Loading @@ -105,3 +105,4 @@ class Backend(BaseBackend): def write_entry(self, key, label, text): self.output(u'\n\n\\bibitem[%s]{%s}\n' % (label, key)) self.output(text)
pybtex/backends/markdown.py +5 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ Markdown output backend. >>> from pybtex.richtext import Tag, HRef >>> markdown = Backend() >>> print Tag('em', '').render(markdown) >>> print(Tag('em', '').render(markdown)) <BLANKLINE> >>> print Tag('em', 'Non-', 'empty').render(markdown) >>> print(Tag('em', 'Non-', 'empty').render(markdown)) *Non\-empty* >>> print HRef('/', '').render(markdown) >>> print(HRef('/', '').render(markdown)) <BLANKLINE> >>> print HRef('/', 'Non-', 'empty').render(markdown) >>> print(HRef('/', 'Non-', 'empty').render(markdown)) [Non\-empty](/) """ from __future__ import unicode_literals Loading Loading @@ -123,3 +123,4 @@ class Backend(BaseBackend): else: self.output(u'[%s] ' % label) self.output(u'%s \n' % text)
pybtex/bibtex/bst.py +8 −7 Original line number Diff line number Diff line Loading @@ -49,19 +49,19 @@ quote_or_comment = re.compile(r'[%"]') def strip_comment(line): """Strip the commented part of the line." >>> print strip_comment('a normal line') >>> print(strip_comment('a normal line')) a normal line >>> print strip_comment('%') >>> print(strip_comment('%')) <BLANKLINE> >>> print strip_comment('%comment') >>> print(strip_comment('%comment')) <BLANKLINE> >>> print strip_comment('trailing%') >>> print(strip_comment('trailing%')) trailing >>> print strip_comment('a normal line% and a comment') >>> print(strip_comment('a normal line% and a comment')) a normal line >>> print strip_comment('"100% compatibility" is a myth') >>> print(strip_comment('"100% compatibility" is a myth')) "100% compatibility" is a myth >>> print strip_comment('"100% compatibility" is a myth% or not?') >>> print(strip_comment('"100% compatibility" is a myth% or not?')) "100% compatibility" is a myth """ Loading Loading @@ -165,3 +165,4 @@ if __name__ == '__main__': import sys from pprint import pprint pprint(parse_file(sys.argv[1]))
pybtex/bibtex/names.py +10 −9 Original line number Diff line number Diff line Loading @@ -22,23 +22,23 @@ """BibTeX-like name formatting. >>> name = 'Charles Louis Xavier Joseph de la Vallee Poussin' >>> print format_name(name, '{vv~}{ll}{, jj}{, f.}') >>> print(format_name(name, '{vv~}{ll}{, jj}{, f.}')) de~la Vallee~Poussin, C.~L. X.~J. >>> name = 'abc' >>> print format_name(name, '{vv~}{ll}{, jj}{, f.}') >>> print(format_name(name, '{vv~}{ll}{, jj}{, f.}')) abc >>> name = 'Jean-Pierre Hansen' >>> print format_name(name, '{ff~}{vv~}{ll}{, jj}') >>> print(format_name(name, '{ff~}{vv~}{ll}{, jj}')) Jean-Pierre Hansen >>> print format_name(name, '{f.~}{vv~}{ll}{, jj}') >>> print(format_name(name, '{f.~}{vv~}{ll}{, jj}')) J.-P. Hansen >>> name = 'F. Phidias Phony-Baloney' >>> print format_name(name, '{v{}}{l}') >>> print(format_name(name, '{v{}}{l}')) P.-B >>> print format_name(name, '{v{}}{l.}') >>> print(format_name(name, '{v{}}{l.}')) P.-B. >>> print format_name(name, '{v{}}{l{}}') >>> print(format_name(name, '{v{}}{l{}}')) PB """ from __future__ import unicode_literals Loading Loading @@ -260,9 +260,9 @@ def join(words, tie='~', space=' '): Otherwise space is inserted. Should produce the same oubput as BibTeX. >>> print join(['a', 'long', 'long', 'road']) >>> print(join(['a', 'long', 'long', 'road'])) a~long long~road >>> print join(['very', 'long', 'phrase']) >>> print(join(['very', 'long', 'phrase'])) very long~phrase """ Loading Loading @@ -365,3 +365,4 @@ class NameFormatParser(Scanner): def eat_whitespace(self): pass