Skip to content

Commit 9e98dc2

Browse files
committed
Highlight syntax of examples
1 parent 8214a29 commit 9e98dc2

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

README.mdown

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,67 @@ Mobi Python Library
44

55
This library provides a little API for accessing the contents of an unencrypted .mobi file. Here's a short example:
66

7-
from mobi import Mobi
8-
9-
book = Mobi("test/CharlesDarwin.mobi");
10-
book.parse();
11-
12-
# this will print, 1 record at a time, the entire contents of the book
13-
for record in book:
14-
print record,
7+
```python
8+
from mobi import Mobi
159

10+
book = Mobi("test/CharlesDarwin.mobi");
11+
book.parse();
12+
# this will print, 1 record at a time, the entire contents of the book
13+
for record in book:
14+
print record
15+
```
1616
This library provides quite a lot of access to the metadata included in any mobibook. For example, Gutenburg's Origin of the Species:
17-
18-
>>> pprint(book.config)
19-
{'exth': {'header length': 356,
20-
'identifier': 1163416648,
21-
'record Count': 15,
22-
'records': {100: 'Charles Darwin',
23-
101: 'Project Gutenberg',
24-
105: 'Natural selection',
25-
106: '1999-12-01',
26-
109: 'Public domain in the USA.',
27-
112: 'http://www.gutenberg.org/files/2009/2009-h/2009-h.htm',
28-
201: '\x00\x00\x00\x00',
29-
202: '\x00\x00\x00\x01',
30-
203: '\x00\x00\x00\x00',
31-
204: '\x00\x00\x00\x01',
32-
205: '\x00\x00\x00\x06',
33-
206: '\x00\x00\x00\x02',
34-
207: '\x00\x00\x00)',
35-
300: '\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\xed\xec\xbe@\x94'}},
36-
'mobi': {'DRM Count': 0,
37-
'DRM Flags': 0,
38-
'DRM Offset': 4294967295,
39-
'DRM Size': 0,
40-
'EXTH flags': 80,
41-
'First Image index': 334,
42-
'First Non-book index': 329,
43-
'Format version': 6,
44-
'Full Name': 'The Origin of Species by means of Natural Selection, 6th Edition',
45-
'Full Name Length': 64,
46-
'Full Name Offset': 604,
47-
'Generator version': 6,
48-
'Has DRM': False,
49-
'Has EXTH Header': True,
50-
'Input Language': 0,
51-
'Language': 9,
52-
'Mobi type': 2,
53-
'Output Language': 0,
54-
'Start Offset': 2808,
55-
'Unique-ID': 4046349163,
56-
'header length': 232,
57-
'identifier': 1297039945,
58-
'text Encoding': 1252},
59-
'palmdoc': {'Compression': 2,
60-
'Encryption Type': 0,
61-
'Unknown': 0,
62-
'Unused': 0,
63-
'record count': 327,
64-
'record size': 4096,
65-
'text length': 1336365}}
66-
>>>
67-
17+
```json
18+
>>> pprint(book.config)
19+
{'exth': {'header length': 356,
20+
'identifier': 1163416648,
21+
'record Count': 15,
22+
'records': {100: 'Charles Darwin',
23+
101: 'Project Gutenberg',
24+
105: 'Natural selection',
25+
106: '1999-12-01',
26+
109: 'Public domain in the USA.',
27+
112: 'http://www.gutenberg.org/files/2009/2009-h/2009-h.htm',
28+
201: '\x00\x00\x00\x00',
29+
202: '\x00\x00\x00\x01',
30+
203: '\x00\x00\x00\x00',
31+
204: '\x00\x00\x00\x01',
32+
205: '\x00\x00\x00\x06',
33+
206: '\x00\x00\x00\x02',
34+
207: '\x00\x00\x00)',
35+
300: '\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf4\xed\xec\xbe@\x94'}},
36+
'mobi': {'DRM Count': 0,
37+
'DRM Flags': 0,
38+
'DRM Offset': 4294967295,
39+
'DRM Size': 0,
40+
'EXTH flags': 80,
41+
'First Image index': 334,
42+
'First Non-book index': 329,
43+
'Format version': 6,
44+
'Full Name': 'The Origin of Species by means of Natural Selection, 6th Edition',
45+
'Full Name Length': 64,
46+
'Full Name Offset': 604,
47+
'Generator version': 6,
48+
'Has DRM': False,
49+
'Has EXTH Header': True,
50+
'Input Language': 0,
51+
'Language': 9,
52+
'Mobi type': 2,
53+
'Output Language': 0,
54+
'Start Offset': 2808,
55+
'Unique-ID': 4046349163,
56+
'header length': 232,
57+
'identifier': 1297039945,
58+
'text Encoding': 1252},
59+
'palmdoc': {'Compression': 2,
60+
'Encryption Type': 0,
61+
'Unknown': 0,
62+
'Unused': 0,
63+
'record count': 327,
64+
'record size': 4096,
65+
'text length': 1336365}}
66+
>>>
67+
```
6868
## Retrieving Author and Title
6969
The author and title of a book can be retrieved using the author() and title()
7070
methods respectively on a Mobi() object. The parse() method needs to have

0 commit comments

Comments
 (0)