BabelDOC 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. babeldoc/__init__.py +1 -0
  2. babeldoc/asynchronize/__init__.py +51 -0
  3. babeldoc/const.py +7 -0
  4. babeldoc/converter.py +510 -0
  5. babeldoc/document_il/__init__.py +43 -0
  6. babeldoc/document_il/backend/__init__.py +0 -0
  7. babeldoc/document_il/backend/pdf_creater.py +402 -0
  8. babeldoc/document_il/frontend/__init__.py +0 -0
  9. babeldoc/document_il/frontend/il_creater.py +348 -0
  10. babeldoc/document_il/il_version_1.py +799 -0
  11. babeldoc/document_il/il_version_1.rnc +141 -0
  12. babeldoc/document_il/il_version_1.rng +390 -0
  13. babeldoc/document_il/il_version_1.xsd +235 -0
  14. babeldoc/document_il/midend/__init__.py +0 -0
  15. babeldoc/document_il/midend/add_debug_information.py +138 -0
  16. babeldoc/document_il/midend/il_translator.py +553 -0
  17. babeldoc/document_il/midend/layout_parser.py +180 -0
  18. babeldoc/document_il/midend/paragraph_finder.py +452 -0
  19. babeldoc/document_il/midend/remove_descent.py +168 -0
  20. babeldoc/document_il/midend/styles_and_formulas.py +701 -0
  21. babeldoc/document_il/midend/typesetting.py +761 -0
  22. babeldoc/document_il/translator/__init__.py +0 -0
  23. babeldoc/document_il/translator/cache.py +145 -0
  24. babeldoc/document_il/translator/translator.py +267 -0
  25. babeldoc/document_il/utils/fontmap.py +227 -0
  26. babeldoc/document_il/utils/layout_helper.py +467 -0
  27. babeldoc/document_il/utils/style_helper.py +86 -0
  28. babeldoc/document_il/xml_converter.py +51 -0
  29. babeldoc/docvision/README.md +0 -0
  30. babeldoc/docvision/__init__.py +0 -0
  31. babeldoc/docvision/doclayout.py +278 -0
  32. babeldoc/docvision/rpc_doclayout.py +162 -0
  33. babeldoc/high_level.py +468 -0
  34. babeldoc/main.py +466 -0
  35. babeldoc/pdfinterp.py +464 -0
  36. babeldoc/progress_monitor.py +146 -0
  37. babeldoc/translation_config.py +156 -0
  38. babeldoc-0.1.6.dist-info/METADATA +283 -0
  39. babeldoc-0.1.6.dist-info/RECORD +42 -0
  40. babeldoc-0.1.6.dist-info/WHEEL +4 -0
  41. babeldoc-0.1.6.dist-info/entry_points.txt +2 -0
  42. babeldoc-0.1.6.dist-info/licenses/LICENSE +661 -0
@@ -0,0 +1,141 @@
1
+ start = Document
2
+ Document =
3
+ element document {
4
+ Page+,
5
+ attribute totalPages { xsd:int }
6
+ }
7
+ Page =
8
+ element page {
9
+ element mediabox { Box },
10
+ element cropbox { Box },
11
+ PDFXobject*,
12
+ PageLayout*,
13
+ PDFRectangle*,
14
+ PDFFont*,
15
+ PDFParagraph*,
16
+ PDFFigure*,
17
+ PDFCharacter*,
18
+ attribute pageNumber { xsd:int },
19
+ attribute Unit { xsd:string },
20
+ element baseOperations { xsd:string }
21
+ }
22
+ Box =
23
+ element box {
24
+ # from (x,y) to (x2,y2)
25
+ attribute x { xsd:float },
26
+ attribute y { xsd:float },
27
+ attribute x2 { xsd:float },
28
+ attribute y2 { xsd:float }
29
+ }
30
+ PDFXrefId = xsd:int
31
+ PDFFont =
32
+ element pdfFont {
33
+ attribute name { xsd:string },
34
+ attribute fontId { xsd:string },
35
+ attribute xrefId { PDFXrefId },
36
+ attribute encodingLength { xsd:int },
37
+ attribute bold { xsd:boolean }?,
38
+ attribute italic { xsd:boolean }?,
39
+ attribute monospace { xsd:boolean }?,
40
+ attribute serif { xsd:boolean }?,
41
+ attribute ascent { xsd:float }?,
42
+ attribute descent { xsd:float }?
43
+ }
44
+ PDFXobject =
45
+ element pdfXobject {
46
+ attribute xobjId { xsd:int },
47
+ attribute xrefId { PDFXrefId },
48
+ Box,
49
+ PDFFont*,
50
+ element baseOperations { xsd:string }
51
+ }
52
+ PDFCharacter =
53
+ element pdfCharacter {
54
+ attribute vertical { xsd:boolean }?,
55
+ attribute scale { xsd:float }?,
56
+ attribute pdfCharacterId { xsd:int }?,
57
+ attribute char_unicode { xsd:string },
58
+ attribute advance { xsd:float }?,
59
+ # xobject nesting depth
60
+ attribute xobjId { xsd:int }?,
61
+ attribute debug_info { xsd:boolean }?,
62
+ PDFStyle,
63
+ Box
64
+ }
65
+ PageLayout =
66
+ element pageLayout {
67
+ attribute id { xsd:int },
68
+ attribute conf { xsd:float },
69
+ attribute class_name { xsd:string },
70
+ Box
71
+ }
72
+ GraphicState =
73
+ element graphicState {
74
+ attribute linewidth { xsd:float }?,
75
+ attribute dash {
76
+ list { xsd:float+ }
77
+ }?,
78
+ attribute flatness { xsd:float }?,
79
+ attribute intent { xsd:string }?,
80
+ attribute linecap { xsd:int }?,
81
+ attribute linejoin { xsd:int }?,
82
+ attribute miterlimit { xsd:float }?,
83
+ attribute ncolor {
84
+ list { xsd:float+ }
85
+ }?,
86
+ attribute scolor {
87
+ list { xsd:float+ }
88
+ }?,
89
+ attribute strokingColorSpaceName { xsd:string }?,
90
+ attribute nonStrokingColorSpaceName { xsd:string }?,
91
+ attribute passthroughPerCharInstruction { xsd:string }?
92
+ }
93
+ PDFStyle =
94
+ element pdfStyle {
95
+ attribute font_id { xsd:string },
96
+ attribute font_size { xsd:float },
97
+ GraphicState
98
+ }
99
+ PDFParagraph =
100
+ element pdfParagraph {
101
+ attribute xobjId { xsd:int }?,
102
+ attribute unicode { xsd:string },
103
+ attribute scale { xsd:float }?,
104
+ attribute vertical { xsd:boolean }?,
105
+ attribute FirstLineIndent { xsd:boolean }?,
106
+ attribute debug_id { xsd:string }?,
107
+ Box,
108
+ PDFStyle,
109
+ PDFParagraphComposition*
110
+ }
111
+ PDFParagraphComposition =
112
+ element pdfParagraphComposition {
113
+ PDFLine
114
+ | PDFFormula
115
+ | PDFSameStyleCharacters
116
+ | PDFCharacter
117
+ | PDFSameStyleUnicodeCharacters
118
+ }
119
+ PDFLine = element pdfLine { Box, PDFCharacter+ }
120
+ PDFSameStyleCharacters =
121
+ element pdfSameStyleCharacters { Box, PDFStyle, PDFCharacter+ }
122
+ PDFSameStyleUnicodeCharacters =
123
+ element pdfSameStyleUnicodeCharacters {
124
+ PDFStyle?,
125
+ attribute unicode { xsd:string },
126
+ attribute debug_info { xsd:boolean }?
127
+ }
128
+ PDFFormula =
129
+ element pdfFormula {
130
+ Box,
131
+ PDFCharacter+,
132
+ attribute x_offset { xsd:float },
133
+ attribute y_offset { xsd:float }
134
+ }
135
+ PDFFigure = element pdfFigure { Box }
136
+ PDFRectangle =
137
+ element pdfRectangle {
138
+ Box,
139
+ GraphicState,
140
+ attribute debug_info { xsd:boolean }?
141
+ }
@@ -0,0 +1,390 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <start>
4
+ <ref name="Document"/>
5
+ </start>
6
+ <define name="Document">
7
+ <element name="document">
8
+ <oneOrMore>
9
+ <ref name="Page"/>
10
+ </oneOrMore>
11
+ <attribute name="totalPages">
12
+ <data type="int"/>
13
+ </attribute>
14
+ </element>
15
+ </define>
16
+ <define name="Page">
17
+ <element name="page">
18
+ <element name="mediabox">
19
+ <ref name="Box"/>
20
+ </element>
21
+ <element name="cropbox">
22
+ <ref name="Box"/>
23
+ </element>
24
+ <zeroOrMore>
25
+ <ref name="PDFXobject"/>
26
+ </zeroOrMore>
27
+ <zeroOrMore>
28
+ <ref name="PageLayout"/>
29
+ </zeroOrMore>
30
+ <zeroOrMore>
31
+ <ref name="PDFRectangle"/>
32
+ </zeroOrMore>
33
+ <zeroOrMore>
34
+ <ref name="PDFFont"/>
35
+ </zeroOrMore>
36
+ <zeroOrMore>
37
+ <ref name="PDFParagraph"/>
38
+ </zeroOrMore>
39
+ <zeroOrMore>
40
+ <ref name="PDFFigure"/>
41
+ </zeroOrMore>
42
+ <zeroOrMore>
43
+ <ref name="PDFCharacter"/>
44
+ </zeroOrMore>
45
+ <attribute name="pageNumber">
46
+ <data type="int"/>
47
+ </attribute>
48
+ <attribute name="Unit">
49
+ <data type="string"/>
50
+ </attribute>
51
+ <element name="baseOperations">
52
+ <data type="string"/>
53
+ </element>
54
+ </element>
55
+ </define>
56
+ <define name="Box">
57
+ <element name="box">
58
+ <!-- from (x,y) to (x2,y2) -->
59
+ <attribute name="x">
60
+ <data type="float"/>
61
+ </attribute>
62
+ <attribute name="y">
63
+ <data type="float"/>
64
+ </attribute>
65
+ <attribute name="x2">
66
+ <data type="float"/>
67
+ </attribute>
68
+ <attribute name="y2">
69
+ <data type="float"/>
70
+ </attribute>
71
+ </element>
72
+ </define>
73
+ <define name="PDFXrefId">
74
+ <data type="int"/>
75
+ </define>
76
+ <define name="PDFFont">
77
+ <element name="pdfFont">
78
+ <attribute name="name">
79
+ <data type="string"/>
80
+ </attribute>
81
+ <attribute name="fontId">
82
+ <data type="string"/>
83
+ </attribute>
84
+ <attribute name="xrefId">
85
+ <ref name="PDFXrefId"/>
86
+ </attribute>
87
+ <attribute name="encodingLength">
88
+ <data type="int"/>
89
+ </attribute>
90
+ <optional>
91
+ <attribute name="bold">
92
+ <data type="boolean"/>
93
+ </attribute>
94
+ </optional>
95
+ <optional>
96
+ <attribute name="italic">
97
+ <data type="boolean"/>
98
+ </attribute>
99
+ </optional>
100
+ <optional>
101
+ <attribute name="monospace">
102
+ <data type="boolean"/>
103
+ </attribute>
104
+ </optional>
105
+ <optional>
106
+ <attribute name="serif">
107
+ <data type="boolean"/>
108
+ </attribute>
109
+ </optional>
110
+ <optional>
111
+ <attribute name="ascent">
112
+ <data type="float"/>
113
+ </attribute>
114
+ </optional>
115
+ <optional>
116
+ <attribute name="descent">
117
+ <data type="float"/>
118
+ </attribute>
119
+ </optional>
120
+ </element>
121
+ </define>
122
+ <define name="PDFXobject">
123
+ <element name="pdfXobject">
124
+ <attribute name="xobjId">
125
+ <data type="int"/>
126
+ </attribute>
127
+ <attribute name="xrefId">
128
+ <ref name="PDFXrefId"/>
129
+ </attribute>
130
+ <ref name="Box"/>
131
+ <zeroOrMore>
132
+ <ref name="PDFFont"/>
133
+ </zeroOrMore>
134
+ <element name="baseOperations">
135
+ <data type="string"/>
136
+ </element>
137
+ </element>
138
+ </define>
139
+ <define name="PDFCharacter">
140
+ <element name="pdfCharacter">
141
+ <optional>
142
+ <attribute name="vertical">
143
+ <data type="boolean"/>
144
+ </attribute>
145
+ </optional>
146
+ <optional>
147
+ <attribute name="scale">
148
+ <data type="float"/>
149
+ </attribute>
150
+ </optional>
151
+ <optional>
152
+ <attribute name="pdfCharacterId">
153
+ <data type="int"/>
154
+ </attribute>
155
+ </optional>
156
+ <attribute name="char_unicode">
157
+ <data type="string"/>
158
+ </attribute>
159
+ <optional>
160
+ <attribute name="advance">
161
+ <data type="float"/>
162
+ </attribute>
163
+ </optional>
164
+ <optional>
165
+ <!-- xobject nesting depth -->
166
+ <attribute name="xobjId">
167
+ <data type="int"/>
168
+ </attribute>
169
+ </optional>
170
+ <optional>
171
+ <attribute name="debug_info">
172
+ <data type="boolean"/>
173
+ </attribute>
174
+ </optional>
175
+ <ref name="PDFStyle"/>
176
+ <ref name="Box"/>
177
+ </element>
178
+ </define>
179
+ <define name="PageLayout">
180
+ <element name="pageLayout">
181
+ <attribute name="id">
182
+ <data type="int"/>
183
+ </attribute>
184
+ <attribute name="conf">
185
+ <data type="float"/>
186
+ </attribute>
187
+ <attribute name="class_name">
188
+ <data type="string"/>
189
+ </attribute>
190
+ <ref name="Box"/>
191
+ </element>
192
+ </define>
193
+ <define name="GraphicState">
194
+ <element name="graphicState">
195
+ <optional>
196
+ <attribute name="linewidth">
197
+ <data type="float"/>
198
+ </attribute>
199
+ </optional>
200
+ <optional>
201
+ <attribute name="dash">
202
+ <list>
203
+ <oneOrMore>
204
+ <data type="float"/>
205
+ </oneOrMore>
206
+ </list>
207
+ </attribute>
208
+ </optional>
209
+ <optional>
210
+ <attribute name="flatness">
211
+ <data type="float"/>
212
+ </attribute>
213
+ </optional>
214
+ <optional>
215
+ <attribute name="intent">
216
+ <data type="string"/>
217
+ </attribute>
218
+ </optional>
219
+ <optional>
220
+ <attribute name="linecap">
221
+ <data type="int"/>
222
+ </attribute>
223
+ </optional>
224
+ <optional>
225
+ <attribute name="linejoin">
226
+ <data type="int"/>
227
+ </attribute>
228
+ </optional>
229
+ <optional>
230
+ <attribute name="miterlimit">
231
+ <data type="float"/>
232
+ </attribute>
233
+ </optional>
234
+ <optional>
235
+ <attribute name="ncolor">
236
+ <list>
237
+ <oneOrMore>
238
+ <data type="float"/>
239
+ </oneOrMore>
240
+ </list>
241
+ </attribute>
242
+ </optional>
243
+ <optional>
244
+ <attribute name="scolor">
245
+ <list>
246
+ <oneOrMore>
247
+ <data type="float"/>
248
+ </oneOrMore>
249
+ </list>
250
+ </attribute>
251
+ </optional>
252
+ <optional>
253
+ <attribute name="strokingColorSpaceName">
254
+ <data type="string"/>
255
+ </attribute>
256
+ </optional>
257
+ <optional>
258
+ <attribute name="nonStrokingColorSpaceName">
259
+ <data type="string"/>
260
+ </attribute>
261
+ </optional>
262
+ <optional>
263
+ <attribute name="passthroughPerCharInstruction">
264
+ <data type="string"/>
265
+ </attribute>
266
+ </optional>
267
+ </element>
268
+ </define>
269
+ <define name="PDFStyle">
270
+ <element name="pdfStyle">
271
+ <attribute name="font_id">
272
+ <data type="string"/>
273
+ </attribute>
274
+ <attribute name="font_size">
275
+ <data type="float"/>
276
+ </attribute>
277
+ <ref name="GraphicState"/>
278
+ </element>
279
+ </define>
280
+ <define name="PDFParagraph">
281
+ <element name="pdfParagraph">
282
+ <optional>
283
+ <attribute name="xobjId">
284
+ <data type="int"/>
285
+ </attribute>
286
+ </optional>
287
+ <attribute name="unicode">
288
+ <data type="string"/>
289
+ </attribute>
290
+ <optional>
291
+ <attribute name="scale">
292
+ <data type="float"/>
293
+ </attribute>
294
+ </optional>
295
+ <optional>
296
+ <attribute name="vertical">
297
+ <data type="boolean"/>
298
+ </attribute>
299
+ </optional>
300
+ <optional>
301
+ <attribute name="FirstLineIndent">
302
+ <data type="boolean"/>
303
+ </attribute>
304
+ </optional>
305
+ <optional>
306
+ <attribute name="debug_id">
307
+ <data type="string"/>
308
+ </attribute>
309
+ </optional>
310
+ <ref name="Box"/>
311
+ <ref name="PDFStyle"/>
312
+ <zeroOrMore>
313
+ <ref name="PDFParagraphComposition"/>
314
+ </zeroOrMore>
315
+ </element>
316
+ </define>
317
+ <define name="PDFParagraphComposition">
318
+ <element name="pdfParagraphComposition">
319
+ <choice>
320
+ <ref name="PDFLine"/>
321
+ <ref name="PDFFormula"/>
322
+ <ref name="PDFSameStyleCharacters"/>
323
+ <ref name="PDFCharacter"/>
324
+ <ref name="PDFSameStyleUnicodeCharacters"/>
325
+ </choice>
326
+ </element>
327
+ </define>
328
+ <define name="PDFLine">
329
+ <element name="pdfLine">
330
+ <ref name="Box"/>
331
+ <oneOrMore>
332
+ <ref name="PDFCharacter"/>
333
+ </oneOrMore>
334
+ </element>
335
+ </define>
336
+ <define name="PDFSameStyleCharacters">
337
+ <element name="pdfSameStyleCharacters">
338
+ <ref name="Box"/>
339
+ <ref name="PDFStyle"/>
340
+ <oneOrMore>
341
+ <ref name="PDFCharacter"/>
342
+ </oneOrMore>
343
+ </element>
344
+ </define>
345
+ <define name="PDFSameStyleUnicodeCharacters">
346
+ <element name="pdfSameStyleUnicodeCharacters">
347
+ <optional>
348
+ <ref name="PDFStyle"/>
349
+ </optional>
350
+ <attribute name="unicode">
351
+ <data type="string"/>
352
+ </attribute>
353
+ <optional>
354
+ <attribute name="debug_info">
355
+ <data type="boolean"/>
356
+ </attribute>
357
+ </optional>
358
+ </element>
359
+ </define>
360
+ <define name="PDFFormula">
361
+ <element name="pdfFormula">
362
+ <ref name="Box"/>
363
+ <oneOrMore>
364
+ <ref name="PDFCharacter"/>
365
+ </oneOrMore>
366
+ <attribute name="x_offset">
367
+ <data type="float"/>
368
+ </attribute>
369
+ <attribute name="y_offset">
370
+ <data type="float"/>
371
+ </attribute>
372
+ </element>
373
+ </define>
374
+ <define name="PDFFigure">
375
+ <element name="pdfFigure">
376
+ <ref name="Box"/>
377
+ </element>
378
+ </define>
379
+ <define name="PDFRectangle">
380
+ <element name="pdfRectangle">
381
+ <ref name="Box"/>
382
+ <ref name="GraphicState"/>
383
+ <optional>
384
+ <attribute name="debug_info">
385
+ <data type="boolean"/>
386
+ </attribute>
387
+ </optional>
388
+ </element>
389
+ </define>
390
+ </grammar>