diff --git a/tablib/formats/_html.py b/tablib/formats/_html.py index 786d5a3..13dc055 100644 --- a/tablib/formats/_html.py +++ b/tablib/formats/_html.py @@ -8,9 +8,12 @@ from StringIO import StringIO from tablib.packages import markup import tablib +BOOK_ENDINGS = 'h3' + title = 'html' extentions = ('html', ) + def export_set(dataset): """HTML representation of a Dataset.""" @@ -35,3 +38,16 @@ def export_set(dataset): return stream.getvalue() + +def export_book(databook): + """HTML representation of a Databook.""" + + stream = StringIO() + + for i, dset in enumerate(databook._datasets): + title = (dset.title if dset.title else 'Set %s' % (i)) + stream.write('<%s>%s\n' % (BOOK_ENDINGS, title, BOOK_ENDINGS)) + stream.write(dset.html) + stream.write('\n') + + return stream.getvalue()