[epub, mobi] fix for IT #3356 - new line char is problemtic in toc.ncx - replace...
[librarian.git] / scripts / book2txt
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 #
7 from librarian.book2anything import Book2Anything, Option
8 from librarian.parser import WLDocument
9
10
11 class Book2Txt(Book2Anything):
12     format_name = "TXT"
13     ext = "txt"
14     uses_cover = False
15     uses_provider = False
16     parser_options = [
17         Option('-i', '--ignore-dublin-core', dest='parse_dublincore', 
18                 action='store_false', default=True,
19                 help='don\'t try to parse dublin core metadata')
20     ]
21     transform_options = [
22         Option('-w', '--wrap', action='store', type='int', dest='wrapping', default=0,
23                 help='set line wrap column')
24     ]
25     transform_flags = [
26         Option('-r', '--raw', dest='raw-text', 
27                 action='store_true', default=False,
28                 help='Produce raw text, without any surrounding info.')
29     ]
30     transform = WLDocument.as_text
31
32
33 if __name__ == '__main__':
34     Book2Txt.run()