1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
3

T'íc@ã"@sldZddlmZddlmZdZddlZddlZddlZddl	Z	ddl
Z
ejdJkr\eZ
eZGdd„deƒZGd	d
„d
eƒZejdKkršGdd„de
ƒZne
Zd
d„ZdLdd„ZGdd„deeƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGd d!„d!eƒZGd"d#„d#eƒZGd$d%„d%eƒZGd&d'„d'eƒZ Gd(d)„d)eƒZ!Gd*d+„d+eƒZ"Gd,d-„d-e"ƒZ#Gd.d/„d/e"ƒZ$Gd0d1„d1e"ƒZ%Gd2d3„d3e"ƒZ&Gd4d5„d5eƒZ'Gd6d7„d7eƒZ(Gd8d9„d9eƒZ)Gd:d;„d;eƒZ*Gd<d=„d=eƒZ+Gd>d?„d?eƒZ,Gd@dA„dAee!eƒZ-GdBdC„dCeeeƒZ.GdDdE„dEeeeƒZ/GdFdG„dGeeƒZ0GdHdI„dIeeƒZ1GdJdK„dKeeƒZ2GdLdM„dMeeƒZ3GdNdO„dOeeƒZ4GdPdQ„dQeeƒZ5GdRdS„dSeeƒZ6GdTdU„dUeeƒZ7GdVdW„dWeeƒZ8GdXdY„dYeeƒZ9GdZd[„d[eeƒZ:Gd\d]„d]eeƒZ;Gd^d_„d_e eƒZ<Gd`da„dae eƒZ=Gdbdc„dce eƒZ>Gddde„dee!eƒZ?Gdfdg„dge!eƒZ@Gdhdi„die!eƒZAGdjdk„dke!eƒZBGdldm„dme#eƒZCGdndo„doe#eƒZDGdpdq„dqe#eƒZEGdrds„dse$eƒZFGdtdu„due$eƒZGGdvdw„dwe(eƒZHGdxdy„dye$eƒZIGdzd{„d{e(eƒZJGd|d}„d}e(eƒZKGd~d„de(eƒZLGd€d„de(eƒZMGd‚dƒ„dƒe$eƒZNGd„d…„d…e(eƒZOGd†d‡„d‡e(eƒZPGdˆd‰„d‰e(eƒZQGdŠd‹„d‹e(eƒZRGdŒd„de(eƒZSGdŽd„de(eƒZTGdd‘„d‘e$eƒZUGd’d“„d“e(eƒZVGd”d•„d•e(eƒZWGd–d—„d—e(eƒZXGd˜d™„d™e#eƒZYGdšd›„d›e#eƒZZGdœd„de#eƒZ[GdždŸ„dŸe#eƒZ\Gd d¡„d¡e(eƒZ]Gd¢d£„d£e#eƒZ^Gd¤d¥„d¥e(eƒZ_Gd¦d§„d§e%eƒZ`Gd¨d©„d©e%eƒZaGdªd«„d«e%eƒZbGd¬d­„d­e%eƒZcGd®d¯„d¯e%eƒZdGd°d±„d±e%eƒZeGd²d³„d³e%eƒZfGd´dµ„dµe%eƒZgGd¶d·„d·e%eƒZhGd¸d¹„d¹e%eƒZiGdºd»„d»e&e'eƒZjGd¼d½„d½e&e'eƒZkGd¾d¿„d¿e&e'e)ee+ƒZlGdÀdÁ„dÁe#eee,e+ƒZmGdÂdÄdÃe#eee,e+ƒZnGdÄdńdÅe(eƒZoGdÆdDŽdÇe#eƒZpGdÈdɄdÉe(eƒZqGdÊd˄dËe(eƒZrGdÌd̈́dÍe#eƒZsGdÎdτdÏe(eƒZtGdÐdфdÑe(eƒZuGdÒdӄdÓe(eƒZvGdÔdՄdÕe(eƒZwGdÖdׄd×e(eƒZxGdØdلdÙe(eƒZyGdÚdۄdÛe&eeeƒZzGdÜd݄dÝe&e'eƒZ{GdÞd߄dße&e)eeƒZ|Gdàdá„dáe)eƒZ}Gdâdã„dãe)eƒZ~Gdädå„dåe)eƒZGdædç„dçe#e)e*eƒZ€Gdèdé„dée)e*eƒZGdêdë„dëe)e*eƒZ‚Gdìdí„díe)eƒZƒGdîdï„dïe)eƒZ„Gdðdñ„dñe)eƒZ…Gdòdó„dóe)eƒZ†Gdôdõ„dõe)eƒZ‡Gdöd÷„d÷e)eƒZˆGdødù„dùe)eƒZ‰Gdúdû„dûe#e)eƒZŠGdüdý„dýe)eƒZ‹Gdþdÿ„dÿe)eƒZŒGdd„de)eƒZdjŽƒZGdd„deƒZGdd„deƒZ‘Gdd„deƒZ’d	d
„Z“dd„Z”d
d„Z•dd„Z–e–eƒGdd„de’ƒZ—Gdd„de˜ƒZ™Gdd„de™ƒZšGdd„de™ƒZ›Gdd„de™ƒZœGdd„de™ƒZGdd„de™ƒZžGdd „d e™ƒZŸd!d"„Z ej¡d#ƒZ¢ej¡d$ƒZ£d%d&d'd(d)d*d+d+d,d&d-d.d)d/d0d*d*d1d2d3d2d)d/d*d4d,d5d2d6d4d7d8d1d9œ!Z¤d:d;d<d=d>d?œZ¥d@dA„Z¦dBdC„Z§dDdE„Z¨dFdG„Z©dHdI„ZªdS(MaØ
Docutils document tree element class library.

Classes in CamelCase are abstract base classes or auxiliary classes. The one
exception is `Text`, for a text (PCDATA) node; uppercase is used to
differentiate from element classes.  Classes in lower_case_with_underscores
are element classes, matching the XML element generic identifiers in the DTD_.

The position of each node (the level at which it can occur) is significant and
is represented by abstract base classes (`Root`, `Structural`, `Body`,
`Inline`, etc.).  Certain transformations will be easier because we can use
``isinstance(node, base_class)`` to determine the position of the node in the
hierarchy.

.. _DTD: http://docutils.sourceforge.net/docs/ref/docutils.dtd
é)Úprint_function)ÚCounterZreStructuredTextNéc@seZdZdZdd„ZeejƒZeejƒZeejƒZeej	ƒZ	eej
ƒZ
eejƒZeejƒZeej
ƒZ
eejƒZeejƒZeejƒZeejƒZdS)Ú_traversal_listFcsd‰‡‡fdd„}|S)Nzm
   The iterable returned by Node.traverse()
   will become an iterator instead of a list in Docutils > 0.16.cs,|jstjˆtddd|_ˆ|f|ž|ŽS)Né)Ú
stacklevelT)ÚdoneÚwarningsÚwarnÚ
FutureWarning)ÚselfÚargsÚkwargs)ÚfunÚmsg©ú2/tmp/pip-build-gk9425m9/docutils/docutils/nodes.pyÚwrapper,sz3_traversal_list._warning_decorator.<locals>.wrapperr)rrr)rrrÚ_warning_decorator(sz"_traversal_list._warning_decoratorN)Ú__name__Ú
__module__Ú__qualname__rrÚlistÚ__add__Ú__contains__Ú__getitem__Ú__reversed__Ú__setitem__ÚappendÚcountÚextendÚindexÚinsertÚpopÚreverserrrrr%s










rc@sÔeZdZdZdZdZdZdZedd„ƒZ	e	j
dd„ƒZ	dd„Zej
d)krLeZej
d*kr^d
d„Zd+dd
„Zd,dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd-d#d$„Zd.d%d&„Zd/d'd(„ZdS)0ÚNodez0Abstract base class of nodes in a document tree.NcCs(y|jp|jjStk
r"dSXdS)zZ
        Return the `document` node at the root of the tree containing this Node.
        N)Ú	_documentÚparentÚdocumentÚAttributeError)rrrrr(Tsz
Node.documentcCs
||_dS)N)r&)rÚvaluerrrr(^scCsdS)a8
        Node instances are always true, even if they're empty.  A node is more
        than a simple container.  Its boolean "truth" does not depend on
        having one or more subnodes in the doctree.

        Use `len()` to check node length.  Use `None` to represent a boolean
        false value.
        Tr)rrrrÚ__bool__bs	z
Node.__bool__rrcCst|ƒjdƒS)NZraw_unicode_escape)ÚunicodeÚencode)rrrrÚ__str__sszNode.__str__cCs&|dkrddljj}|jƒ}|j|ƒS)z6Return a DOM **fragment** representation of this Node.Nr)Úxml.dom.minidomÚdomÚminidomÚDocumentÚ	_dom_node)rr0ÚdomrootrrrÚasdomvsz
Node.asdomú    cCst‚dS)zs
        Return an indented pseudo-XML representation, for test purposes.

        Override in subclasses.
        N)ÚNotImplementedError)rÚindentÚlevelrrrÚpformat}szNode.pformatcCst‚dS)zReturn a copy of self.N)r7)rrrrÚcopy…sz	Node.copycCst‚dS)z3Return a deep copy of self (also copying children).N)r7)rrrrÚdeepcopy‰sz
Node.deepcopycCst‚dS)z,Return a string representation of this Node.N)r7)rrrrÚastextszNode.astextcCs@||_|jr<|j|_|jdkr(|jj|_|jdkr<|jj|_dS)N)r'r(ÚsourceÚcurrent_sourceÚlineÚcurrent_line)rÚchildrrrÚsetup_child‘s


zNode.setup_childcCs¼d}|jjjd|jjƒy„y|j|ƒWn*ttfk
rB|Stk
rTYnX|j	}y*x$|dd…D]}|j
|ƒrld}PqlWWntk
ršYnXWntk
r¶d}YnX|S)aé
        Traverse a tree of `Node` objects, calling the
        `dispatch_visit()` method of `visitor` when entering each
        node.  (The `walkabout()` method is similar, except it also
        calls the `dispatch_departure()` method before exiting each
        node.)

        This tree traversal supports limited in-place tree
        modifications.  Replacing one node with one or more nodes is
        OK, as is removing an element.  However, if the node removed
        or replaced occurs after the current node, the old node will
        still be traversed, and any new nodes will not.

        Within ``visit`` methods (and ``depart`` methods for
        `walkabout()`), `TreePruningException` subclasses may be raised
        (`SkipChildren`, `SkipSiblings`, `SkipNode`, `SkipDeparture`).

        Parameter `visitor`: A `NodeVisitor` object, containing a
        ``visit`` implementation for each `Node` subclass encountered.

        Return true if we should stop the traversal.
        Fz6docutils.nodes.Node.walk calling dispatch_visit for %sNT)
r(ÚreporterÚdebugÚ	__class__rÚdispatch_visitÚSkipChildrenÚSkipNodeÚ
SkipDepartureÚchildrenÚwalkÚSkipSiblingsÚ
StopTraversal)rÚvisitorÚstoprKrBrrrrLšs,



z	Node.walkcCsöd}d}|jjjd|jjƒy„y|j|ƒWn*tk
rB|Stk
rXd}YnX|j}y*x$|dd…D]}|j	|ƒrpd}PqpWWnt
k
ržYnXWn*tk
r¶Yntk
rÌd}YnX|rò|jjjd|jjƒ|j
|ƒ|S)a†
        Perform a tree traversal similarly to `Node.walk()` (which
        see), except also call the `dispatch_departure()` method
        before exiting each node.

        Parameter `visitor`: A `NodeVisitor` object, containing a
        ``visit`` and ``depart`` implementation for each `Node`
        subclass encountered.

        Return true if we should stop the traversal.
        TFz;docutils.nodes.Node.walkabout calling dispatch_visit for %sNz?docutils.nodes.Node.walkabout calling dispatch_departure for %s)r(rDrErFrrGrIrJrKÚ	walkaboutrMrHrNÚdispatch_departure)rrOZcall_departrPrKrBrrrrQÈs<





zNode.walkaboutccs>t||ƒr|Vx(|jD]}x|j|ƒD]
}|Vq(WqWdS)z3Return iterator that only supports instance checks.N)Ú
isinstancerKÚ_fast_traverse)rÚclsrBÚsubnoderrrrTós

zNode._fast_traverseccs2|Vx&|jD]}x|jƒD]
}|VqWqWdS)z3Return iterator that doesn't check for a condition.N)rKÚ
_all_traverse)rrBrVrrrrWûszNode._all_traverseTFcCst|j|||||ƒƒS)a
        Return an iterable containing

        * self (if include_self is true)
        * all descendants in tree traversal order (if descend is true)
        * all siblings (if siblings is true) and their descendants (if
          also descend is true)
        * the siblings of the parent (if ascend is true) and their
          descendants (if also descend is true), and so on

        If `condition` is not None, the iterable contains only nodes
        for which ``condition(node)`` is true.  If `condition` is a
        node class ``cls``, it is equivalent to a function consisting
        of ``return isinstance(node, cls)``.

        If ascend is true, assume siblings to be true as well.

        For example, given the following tree::

            <paragraph>
                <emphasis>      <--- emphasis.traverse() and
                    <strong>    <--- strong.traverse() are called.
                        Foo
                    Bar
                <reference name="Baz" refid="baz">
                    Baz

        Then list(emphasis.traverse()) equals ::

            [<emphasis>, <strong>, <#text: Foo>, <#text: Bar>]

        and list(strong.traverse(ascend=True)) equals ::

            [<strong>, <#text: Foo>, <#text: Bar>, <reference>, <#text: Baz>]
        )rÚ	_traverse)rÚ	conditionÚinclude_selfÚdescendÚsiblingsÚascendrrrÚtraverses)
z
Node.traverseccsV|rd}|rb|rb|rb|dkr:x|jƒD]
}|Vq(WdSt|tƒrbx|j|ƒD]
}|VqPWdSt|tƒr||}|fdd„}|r–|dks||ƒr–|V|rÖt|jƒrÖx0|D](}x"|j|dddddD]
}|VqÄWqªW|sà|rR|}	xl|	jrP|	jj|	ƒ}
xB|	j|
dd…D],}x$|j|d|dddD]}|Vq(WqW|sHPqæ|	j}	qæWdS)z>Return iterator over nodes following `self`. See `traverse()`.TNcSs
t||ƒS)N)rS)ÚnodeÚ
node_classrrrrYBsz!Node._traverse.<locals>.conditionF)rYrZr[r\r]é)	rWrSÚtyperTÚlenrKrXr'r!)rrYrZr[r\r]rVr`rBr_r!ZsiblingrrrrX.sD






zNode._traversecCs4|j|||||ƒ}yt|ƒStk
r.dSXdS)zè
        Return the first node in the iterable returned by traverse(),
        or None if the iterable is empty.

        Parameter list is the same as of traverse.  Note that
        include_self defaults to False, though.
        N)rXÚnextÚ
StopIteration)rrYrZr[r\r]Z
node_iteratorrrrÚ	next_node\s	
zNode.next_node)rr)rr)N)r6r)NTTFF)NTTFF)NFTFF)rrrÚ__doc__r'r>r@r&Úpropertyr(Úsetterr+ÚsysÚversion_infoÚ__nonzero__r.r5r:r;r<r=rCrLrQrTrWr^rXrfrrrrr%Es8




	.+
+
-r%c@seZdZdZdd„ZdS)ÚreprunicodezU
        A unicode sub-class that removes the initial u from unicode's repr.
        cCstj|ƒdd…S)Nra)r,Ú__repr__)rrrrrnrszreprunicode.__repr__N)rrrrgrnrrrrrmmsrmcCs$tjdkr t|tƒr |jddƒS|S)z4
    Failsave conversion of `unicode` to `str`.
    rrÚasciiÚbackslashreplace)rr)rjrkrSr,r-)ÚsrrrÚ
ensure_strxsrrFcCs6|r|jddƒSxdD]}dj|j|ƒƒ}qW|SdS)zw
    Return a string with nulls removed or restored to backslashes.
    Backslash-escaped spaces are also removed.
    úú\ú ú
ÚN)rurvrs)ÚreplaceÚjoinÚsplit)ÚtextZrestore_backslashesZrespect_whitespaceÚseprrrÚunescapes

r}c@s’eZdZdZdZfZejd kr*d!dd„Zn
d"dd„Zd#d
d„Z	d$d
d„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zd%dd„Zd&dd„Zd'dd„ZdS)(ÚTextzÐ
    Instances are terminal nodes (leaves) containing text only; no child
    nodes or attributes.  Initialize by passing a string to the constructor.
    Access the text itself with the `astext` method.
    z#textrrNcCst|tƒrtdƒ‚tj||ƒS)z7Prevent the rawsource argument from propagating to str.zexpecting str data, not bytes)rSÚbytesÚ	TypeErrorrmÚ__new__)rUÚdataÚ	rawsourcerrrrs
zText.__new__cCstj||ƒS)z7Prevent the rawsource argument from propagating to str.)rmr)rUr‚rƒrrrr£srwcCs
||_dS)N)rƒ)rr‚rƒrrrÚ__init__§sz
Text.__init__écCs6|}t|ƒ|kr$|d|d…d}d|jt|ƒfS)Néz ...z<%s: %r>)rcÚtagnamerm)rÚmaxlenr‚rrrÚ	shortrepr«szText.shortreprcCs|jddS)NéD)rˆ)r‰)rrrrrn±sz
Text.__repr__cCs|jt|ƒƒS)N)ZcreateTextNoder,)rr4rrrr3´szText._dom_nodecCstt|ƒƒS)N)rmr})rrrrr=·szText.astextcCs|jt|ƒ|jdS)N)rƒ)rFrmrƒ)rrrrr;Ãsz	Text.copycCs|jƒS)N)r;)rrrrr<Æsz
Text.deepcopyú    cs˜yJ|jjjrHdˆˆdfg‡‡fdd„|jddDƒ}dj|ƒdSWntk
r^YnXˆˆ‰‡fdd„|jƒjƒDƒ}|sŠd	Sdj|ƒdS)
Nz%s%sz<#text>cs g|]}ˆˆdt|ƒ‘qS)ra)Úrepr)Ú.0r@)r8r9rrú
<listcomp>Ísz Text.pformat.<locals>.<listcomp>T)ÚkeependsÚ
csg|]}ˆ|‘qSrr)rr@)r8rrrŽÓsrw)r(ÚsettingsZ	detailledÚ
splitlinesryr)r=)rr8r9Úlinesr)r8r9rr:És
zText.pformatcCs|jtj||ƒ|jƒS)N)rFrmÚrstriprƒ)rÚcharsrrrr”ÜszText.rstripcCs|jtj||ƒ|jƒS)N)rFrmÚlstriprƒ)rr•rrrr–ßszText.lstrip)rr)N)N)rw)r…)r‹r)N)N)rrrrgr‡rKrjrkrr„r‰rnr3r=r;r<r:r”r–rrrrr~s 





r~c@s>eZdZdZd‚ZdƒZeeZed„Zd	Zd
Z	d…dd
„Z
dd„Zdd„Zdd„Z
dd„Zejd†krdeZd‡dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zdˆd4d5„Z d6d7„Z!d8d9„Z"d‰d:d;„Z#e!Z$dŠd<d=„Z%d>d?„Z&d@dA„Z'dBdC„Z(dŒdEdF„Z)dGdH„Z*dIdJ„Z+dKdL„Z,dMdN„Z-dOdP„Z.dQdR„Z/ddTdU„Z0dŽdVdW„Z1dXdY„Z2dZd[„Z3d\d]„Z4e4dSd^fd_d`„Z5ddadb„Z6ddcdd„Z7d‘dedf„Z8d’dgdh„Z9didj„Z:dkdl„Z;dmdn„Z<dej=fdodp„Z>dej=fdqdr„Z?d“dtdu„Z@dvdw„ZAdxdy„ZBdzd{„ZCd”d|d}„ZDeEd~d„ƒZFeEd€d„ƒZGd	S)•ÚElementa‰
    `Element` is the superclass to all specific elements.

    Elements contain attributes and child nodes.  Elements emulate
    dictionaries for attributes, indexing by attribute name (a string).  To
    set the attribute 'att' to 'value', do::

        element['att'] = 'value'

    There are two special attributes: 'ids' and 'names'.  Both are
    lists of unique identifiers, and names serve as human interfaces
    to IDs.  Names are case- and whitespace-normalized (see the
    fully_normalize_name() function), and IDs conform to the regular
    expression ``[a-z](-?[a-z0-9]+)*`` (see the make_id() function).

    Elements also emulate lists for child nodes (element nodes and/or text
    nodes), indexing by integer.  To get the first child node, use::

        element[0]

    Elements may be constructed using the ``+=`` operator.  To add one new
    child node to element, do::

        element += node

    This is equivalent to ``element.append(node)``.

    To add a list of multiple child nodes at once, use the same ``+=``
    operator::

        element += [node1, node2]

    This is equivalent to ``element.extend([node1, node2])``.
    ÚidsÚclassesÚnamesÚdupnamesÚbackrefsr>rƒNz

rwcOs”||_g|_|j|ƒi|_x|jD]}g|j|<q$WxD|jƒD]8\}}|jƒ}||jkrn|dd…|j|<q@||j|<q@W|jdkr|jj	|_dS)N)
rƒrKr Ú
attributesÚlist_attributesÚitemsÚlowerr‡rFr)rrƒrKrÚattr*rrrr„ s


zElement.__init__cCst|j|jƒ}xB|jƒD]6\}}t|tƒr<djdd„|Dƒƒ}|j|d|ƒqWx|jD]}|j|j	|ƒƒqXW|S)Nú cSsg|]}td|fƒ‘qS)z%s)Ú
serial_escape)rÚvrrrrŽBsz%Element._dom_node.<locals>.<listcomp>z%s)
Ú
createElementr‡ÚattlistrSrryZsetAttributerKÚappendChildr3)rr4ÚelementÚ	attributer*rBrrrr3>s
zElement._dom_nodecCs€d}x8|jD].}||jƒ7}t|ƒdkr|dd…d}PqW|drld|jjdjdd	„|dDƒƒ|fSd
|jj|fSdS)Nrwé<é8z ...ršz
<%s "%s": %s>z; cSsg|]}t|ƒ‘qSr)rr)rÚnrrrrŽQsz$Element.__repr__.<locals>.<listcomp>z<%s: %s>)rKr‰rcrFrry)rr‚ÚcrrrrnHszElement.__repr__cCs:|dr,d|jjdjdd„|dDƒƒfSd|jSdS)Nršz<%s "%s"...>z; cSsg|]}t|ƒ‘qSr)rr)rr¬rrrrŽXsz%Element.shortrepr.<locals>.<listcomp>z<%s...>)rFrryr‡)rrrrr‰UszElement.shortreprcCs:|jr.d|jƒdjdd„|jDƒƒ|jƒfS|jƒSdS)Nz%s%s%srwcSsg|]}t|ƒ‘qSr)r,)rr­rrrrŽ_sz'Element.__unicode__.<locals>.<listcomp>)rKÚstarttagryÚendtagÚemptytag)rrrrÚ__unicode__\s
zElement.__unicode__rrcCs–|dkrt}|jg}xr|jƒD]f\}}|dkr>|jd|ƒqt|tƒrbdd„|Dƒ}dj|ƒ}nt|ƒ}||ƒ}|jd||fƒqWddj|ƒS)Nz	%s="True"cSsg|]}td|fƒ‘qS)z%s)r£)rr¤rrrrŽqsz$Element.starttag.<locals>.<listcomp>r¢z%s=%sz<%s>)Úpseudo_quoteattrr‡r¦rrSrryr,)rÚ	quoteattrÚpartsÚnamer*Úvaluesrrrr®gs
zElement.starttagcCs
d|jS)Nz</%s>)r‡)rrrrr¯yszElement.endtagcCs$ddj|jgdd„|jƒDƒƒS)Nz<%s/>r¢cSsg|]\}}d||f‘qS)z%s="%s"r)rr¬r¤rrrrŽ~sz$Element.emptytag.<locals>.<listcomp>)ryr‡r¦)rrrrr°|szElement.emptytagcCs
t|jƒS)N)rcrK)rrrrÚ__len__szElement.__len__cCst|tƒr||jkS||jkS)N)rSÚ
basestringrrK)rÚkeyrrrr„s

zElement.__contains__cCsbt|tƒr|j|St|tƒr(|j|St|tƒrV|jdksDtdƒ‚|j|j|j	…St
dƒ‚dS)Nrazcannot handle slice with stridezFelement index must be an integer, a slice, or an attribute name string)Nra)rSr¸rÚintrKÚsliceÚstepÚAssertionErrorÚstartrPr€)rr¹rrrrŠs




zElement.__getitem__cCsŽt|tƒr||jt|ƒ<npt|tƒr:|j|ƒ||j|<nPt|tƒr‚|jdksVt	dƒ‚x|D]}|j|ƒq\W||j|j
|j…<ntdƒ‚dS)Nrazcannot handle slice with stridezFelement index must be an integer, a slice, or an attribute name string)Nra)
rSr¸rÚstrrºrCrKr»r¼r½r¾rPr€)rr¹Úitemr_rrrr–s




zElement.__setitem__cCsbt|tƒr|j|=nJt|tƒr(|j|=n6t|tƒrV|jdksDtdƒ‚|j|j|j	…=nt
dƒ‚dS)Nrazcannot handle slice with stridezMelement index must be an integer, a simple slice, or an attribute name string)Nra)rSr¸rrºrKr»r¼r½r¾rPr€)rr¹rrrÚ__delitem__¥s




zElement.__delitem__cCs
|j|S)N)rK)rÚotherrrrr±szElement.__add__cCs
||jS)N)rK)rrÂrrrÚ__radd__´szElement.__radd__cCs,t|tƒr|j|ƒn|dk	r(|j|ƒ|S)z4Append a node or a list of nodes to `self.children`.N)rSr%rr )rrÂrrrÚ__iadd__·s


zElement.__iadd__cCs|jjdd„|jDƒƒS)NcSsg|]}|jƒ‘qSr)r=)rrBrrrrŽÁsz"Element.astext.<locals>.<listcomp>)Úchild_text_separatorryrK)rrrrr=¿szElement.astextcCs2i}x(|jjƒD]\}}|j|ƒr|||<qW|S)N)rrŸÚis_not_default)rZattsr¹r*rrrÚnon_default_attributesÃs

zElement.non_default_attributescCst|jƒjƒƒ}|S)N)ÚsortedrÇrŸ)rr¦rrrr¦ÊszElement.attlistcCs|jj||ƒS)N)rÚget)rr¹ÚfailobjrrrrÉÎszElement.getcCs
||jkS)N)r)rÚattrrrrÚhasattrÑszElement.hasattrcCs||jkr|j|=dS)N)r)rrËrrrÚdelattrÔs
zElement.delattrcCs|jj||ƒS)N)rÚ
setdefault)rr¹rÊrrrrÎØszElement.setdefaultcCsRx*|jdgƒD]}|jdƒr|dd…SqWy|jj|ƒStk
rL|SXdS)zîReturn node's language tag.

        Look iteratively in self and parents for a class argument
        starting with ``language-`` and return the remainder of it
        (which should be a `BCP49` language tag) or the `fallback`.
        r™z	language-é	N)rÉÚ
startswithr'Zget_languager))rÚfallbackrUrrrÚget_language_codeÝs
zElement.get_language_codecCs|j|ƒ|jj|ƒdS)N)rCrKr)rrÀrrrrìs
zElement.appendcCsx|D]}|j|ƒqWdS)N)r)rrÀr_rrrr ðs
zElement.extendcCs<t|tƒr$|j|ƒ|jj||ƒn|dk	r8||||…<dS)N)rSr%rCrKr")rr!rÀrrrr"ôs


zElement.insertracCs|jj|ƒS)N)rKr#)rÚirrrr#ûszElement.popcCs|jj|ƒdS)N)rKÚremove)rrÀrrrrÔþszElement.removecCs|jj|ƒS)N)rKr!)rrÀrrrr!sz
Element.indexcCs"||gkr||jkrdSdSdS)Nrra)rž)rr¹rrrrÆszElement.is_not_defaultcCs8t|tƒr|j}x"|jD]}|j||j|gƒƒqWdS)zŒ
        Update basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') from node or dictionary `dict_`.
        N)rSr%rÚbasic_attributesÚappend_attr_listrÉ)rÚdict_r¡rrrÚupdate_basic_atts
s
zElement.update_basic_attscCs,x&|D]}|||kr||j|ƒqWdS)zÜ
        For each element in values, if it does not exist in self[attr], append
        it.

        NOTE: Requires self[attr] and values to be sequence type and the
        former should specifically be a list.
        N)r)rrËr¶r*rrrrÖs	
zElement.append_attr_listcCs>t|j|ƒtƒs||g||<t|tƒs.|g}|j||ƒdS)a
        First, convert both self[attr] and value to a non-string sequence
        type; if either is not already a sequence, convert it to a list of one
        element.  Then call append_attr_list.

        NOTE: self[attr] and value both must not be None.
        N)rSrÉrrÖ)rrËr*rrrÚcoerce_append_attr_list!s
	
zElement.coerce_append_attr_listTcCs|s|j|ƒdkr|||<dS)z‚
        If self[attr] does not exist or force is True or omitted, set
        self[attr] to value, otherwise do nothing.
        N)rÉ)rrËr*ÚforcerrrÚreplace_attr0szElement.replace_attrcCs|j|ƒ|k	r|j||ƒdS)a
        If attr is an attribute of self, set self[attr] to
        [self[attr], value], otherwise set self[attr] to value.

        NOTE: replace is not used by this function and is kept only for
              compatibility with the other copy functions.
        N)rÉrÙ)rrËr*rxrrrÚcopy_attr_convert9szElement.copy_attr_convertcCsH|j|ƒ|k	rDt|j|ƒtƒs(t|tƒr6|j||ƒn|j|||ƒdS)a—
        If attr is an attribute of self and either self[attr] or value is a
        list, convert all non-sequence values to a sequence of 1 element and
        then concatenate the two sequence, setting the result to self[attr].
        If both self[attr] and value are non-sequences and replace is True or
        self[attr] is None, replace self[attr] with value. Otherwise, do
        nothing.
        N)rÉrSrrÙrÛ)rrËr*rxrrrÚcopy_attr_coerceDs
	
zElement.copy_attr_coercecCsH|j|ƒ|k	rDt|j|ƒtƒr6t|tƒr6|j||ƒn|j|||ƒdS)aM
        If attr is an attribute of self and both self[attr] and value are
        lists, concatenate the two sequences, setting the result to
        self[attr].  If either self[attr] or value are non-sequences and
        replace is True or self[attr] is None, replace self[attr] with value.
        Otherwise, do nothing.
        N)rÉrSrrÖrÛ)rrËr*rxrrrÚcopy_attr_concatenateTs

zElement.copy_attr_concatenatecCs |j|ƒ|k	r|j|||ƒdS)zz
        If replace is True or self[attr] is None, replace self[attr] with
        value.  Otherwise, do nothing.
        N)rÉrÛ)rrËr*rxrrrÚcopy_attr_consistentcszElement.copy_attr_consistentFcCsVt|tƒr|j}|r|j}n|j}|j|ƒx$t||ƒD]}||||||ƒq8WdS)a.
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_, the two values are
        merged based on the value of update_fun.  Generally, when replace is
        True, the values in self are replaced or merged with the values in
        dict_; otherwise, the values in self may be preserved or merged.  When
        and_source is True, the 'source' attribute is included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        NOTE: It is easier to call the update-specific methods then to pass
              the update_fun method to this function.
        N)rSr%rÚis_not_list_attributeÚis_not_known_attributerØÚfilter)rr×Z
update_funrxÚ
and_sourceZ
filter_funr¡rrrÚupdate_all_attsks

zElement.update_all_attscCs|j|tj||ƒdS)aC
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ and replace is True, the
        values in self are replaced with the values in dict_; otherwise, the
        values in self are preserved.  When and_source is True, the 'source'
        attribute is included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        N)rär—rß)rr×rxrãrrrÚupdate_all_atts_consistantly‘sz$Element.update_all_atts_consistantlycCs|j|tj||ƒdS)a
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ whose values aren't each
        lists and replace is True, the values in self are replaced with the
        values in dict_; if the values from self and dict_ for the given
        identifier are both of list type, then the two lists are concatenated
        and the result stored in self; otherwise, the values in self are
        preserved.  When and_source is True, the 'source' attribute is
        included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        N)rär—rÞ)rr×rxrãrrrÚupdate_all_atts_concatenating¦sz%Element.update_all_atts_concatenatingcCs|j|tj||ƒdS)a[
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ whose values are both
        not lists and replace is True, the values in self are replaced with
        the values in dict_; if either of the values from self and dict_ for
        the given identifier are of list type, then first any non-lists are
        converted to 1-element lists and then the two lists are concatenated
        and the result stored in self; otherwise, the values in self are
        preserved.  When and_source is True, the 'source' attribute is
        included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        N)rär—rÝ)rr×rxrãrrrÚupdate_all_atts_coercion¾sz Element.update_all_atts_coercioncCs|j|tj|ddS)a}
        Updates all attributes from node or dictionary `dict_`.

        Appends the basic attributes ('ids', 'names', 'classes',
        'dupnames', but not 'source') and then, for all other attributes in
        dict_, updates the same attribute in self.  When attributes with the
        same identifier appear in both self and dict_ then first any non-lists
        are converted to 1-element lists and then the two lists are
        concatenated and the result stored in self; otherwise, the values in
        self are preserved.  When and_source is True, the 'source' attribute
        is included in the copy.

        NOTE: When replace is False, and self contains a 'source' attribute,
              'source' is not replaced even when dict_ has a 'source'
              attribute, though it may still be merged into a list depending
              on the value of update_fun.
        )rãN)rär—rÜ)rr×rãrrrÚupdate_all_atts_convert×s
zElement.update_all_atts_convertcCs
g|_dS)N)rK)rrrrÚclearìsz
Element.clearcCsD|j|ƒ}t|tƒr(|j|ƒ|||<n|dk	r@||||d…<dS)z8Replace one child `Node` with another child or children.Nra)r!rSr%rC)rÚoldÚnewr!rrrrxïs



zElement.replacecCsŠ|}t|tƒs4y|d}Wntk
r2d}YnXt|tƒrJ|j|ƒn.x,|jD]"}||sRtd|||fƒ‚qRW|jj||ƒdS)zc
        Replace `self` node with `new`, where `new` is a node or a
        list of nodes.
        rNzLosing "%s" attribute: %s)	rSr%Ú
IndexErrorr—rØrÕr½r'rx)rrëÚupdater¡rrrÚreplace_selføs


zElement.replace_selfcCsRt|tƒs|f}x<t|tt|ƒ|ƒƒD]$}x|D]}t|||ƒr0|Sq0Wq&WdS)aM
        Return the index of the first child whose class exactly matches.

        Parameters:

        - `childclass`: A `Node` subclass to search for, or a tuple of `Node`
          classes. If a tuple, any of the classes may match.
        - `start`: Initial index to check.
        - `end`: Initial index to *not* check.
        N)rSÚtupleÚrangeÚminrc)rÚ
childclassr¾Úendr!r­rrrÚfirst_child_matching_classs

z"Element.first_child_matching_classcCsVt|tƒs|f}x@t|tt|ƒ|ƒƒD](}x"|D]}t|j||ƒr0Pq0W|Sq&WdS)aI
        Return the index of the first child whose class does *not* match.

        Parameters:

        - `childclass`: A `Node` subclass to skip, or a tuple of `Node`
          classes. If a tuple, none of the classes may match.
        - `start`: Initial index to check.
        - `end`: Initial index to *not* check.
        N)rSrïrðrñrcrK)rròr¾rór!r­rrrÚfirst_child_not_matching_class!s

z&Element.first_child_not_matching_classú    cs2djdˆˆ|jƒfg‡‡fdd„|jDƒƒS)Nrwz%s%s
csg|]}|jˆˆdƒ‘qS)ra)r:)rrB)r8r9rrrŽ9sz#Element.pformat.<locals>.<listcomp>)ryr®rK)rr8r9r)r8r9rr:7szElement.pformatcCs4|jfd|ji|j—Ž}|j|_|j|_|j|_|S)Nrƒ)rFrƒrr&r>r@)rÚobjrrrr;<s
zElement.copycCs"|jƒ}|jdd„|jDƒƒ|S)NcSsg|]}|jƒ‘qSr)r<)rrBrrrrŽEsz$Element.deepcopy.<locals>.<listcomp>)r;r rK)rr;rrrr<CszElement.deepcopycCs2tjdtddd|kst‚|dj|jƒƒdS)z+Add a new class to the "classes" attribute.zadocutils.nodes.Element.set_class deprecated; append to Element['classes'] list attribute directlyr)rr¢r™N)r	r
ÚDeprecationWarningr½rr )rrµrrrÚ	set_classHs
zElement.set_classcCsZd|_t|diƒj|ƒ}t|diƒj|ƒ}|r@|dk	s:t‚d|_|rV|dk	sPt‚d|_dS)zQNote that this Element has been referenced by its name
        `name` or id `id`.raZexpect_referenced_by_nameZexpect_referenced_by_idN)Ú
referencedÚgetattrrÉr½)rrµÚidZby_nameZby_idrrrÚnote_referenced_byPszElement.note_referenced_bycCs
||jkS)z‹
        Returns True if and only if the given attribute is NOT one of the
        basic list attributes defined for all Elements.
        )rž)rUrËrrrràaszElement.is_not_list_attributecCs
||jkS)zj
        Returns True if and only if the given attribute is NOT recognized by
        this class.
        )Úknown_attributes)rUrËrrrráiszElement.is_not_known_attribute)r˜r™ršr›)rœ)r>rƒ)rw)rr)N)N)N)rwéÿÿÿÿ)rÿ)T)T)TF)TF)TF)F)rör)NN)HrrrrgrÕZlocal_attributesržrþr‡rÅr„r3rnr‰r±rjrkr.r®r¯r°r·rrrrÁrrÃrÄr=rÇr¦rÉrÌrÍrÎZhas_keyrÒrr r"r#rÔr!rÆrØrÖrÙrÛrÜrÝrÞrßrärårærçrèrérxrîÚmaxsizerôrõr:r;r<rùrýÚclassmethodràrárrrrr—âsŽ#











	
%



	

r—c@seZdZdZdZddd„ZdS)ÚTextElementaé
    An element which directly contains text.

    Its children are all `Text` or `Inline` subclass nodes.  You can
    check whether an element's context is inline simply by checking whether
    its immediate parent is a `TextElement` instance (including subclasses).
    This is handy for nodes like `image` that can appear both inline and as
    standalone body elements.

    If passing children to `__init__()`, make sure to set `text` to
    ``''`` or some other suitable value.
    rwcOs@|dkr(t|ƒ}tj|||f|ž|Žntj||f|ž|ŽdS)Nrw)r~r—r„)rrƒr{rKrZtextnoderrrr„„s
zTextElement.__init__N)rwrw)rrrrgrÅr„rrrrrrs
rc@seZdZdZddd„ZdS)ÚFixedTextElementz5An element which directly contains preformatted text.rwcOs$tj|||f|ž|Žd|jd<dS)NZpreservez	xml:space)rr„r)rrƒr{rKrrrrr„‘szFixedTextElement.__init__N)rwrw)rrrrgr„rrrrrsrc@seZdZdZdS)Ú
ResolvablerN)rrrZresolvedrrrrršsrc@seZdZdd„ZdS)ÚBackLinkablecCs|dj|ƒdS)Nrœ)r)rÚrefidrrrÚadd_backref¡szBackLinkable.add_backrefN)rrrrrrrrrŸsrc@seZdZdS)ÚRootN)rrrrrrrr©src@seZdZdS)ÚTitularN)rrrrrrrr	­sr	c@seZdZdZdS)ÚPreBibliographicz<Category of Node which may occur before Bibliographic Nodes.N)rrrrgrrrrr
±sr
c@seZdZdS)Ú
BibliographicN)rrrrrrrrµsrc@seZdZdS)Ú
DecorativeN)rrrrrrrr¹src@seZdZdS)Ú
StructuralN)rrrrrrrr
½sr
c@seZdZdS)ÚBodyN)rrrrrrrrÁsrc@seZdZdS)ÚGeneralN)rrrrrrrrÅsrc@seZdZdZdS)Ú
SequentialzList-like elements.N)rrrrgrrrrrÉsrc@seZdZdS)Ú
AdmonitionN)rrrrrrrrÍsrc@seZdZdZdS)ÚSpecialzSpecial internal body elements.N)rrrrgrrrrrÐsrc@seZdZdZdS)Ú	Invisiblez.Internal elements that don't appear in output.N)rrrrgrrrrrÔsrc@seZdZdS)ÚPartN)rrrrrrrrØsrc@seZdZdS)ÚInlineN)rrrrrrrrÜsrc@seZdZdS)ÚReferentialN)rrrrrrrràsrc@seZdZdZdZdS)Ú
TargetablerN)rrrrúZindirect_reference_namerrrrräsrc@seZdZdZdS)ÚLabeledz(Contains a `label` as its first element.N)rrrrgrrrrrísrc@seZdZdZdd„Zdd„Zd>dd„Zd?d
d„Zd@dd
„Zdd„Z	dd„Z
dAdd„ZdBdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„ZdCd.d/„Zd0d1„ZdDd2d3„Zd4d5„Zd6d7„Zd8d9„Zd:d;„Zd<d=„Z dS)Er(z‚
    The document root element.

    Do not instantiate this class directly; use
    `docutils.utils.new_document()` instead.
    cOsÖtj|f|ž|Žd|_d|_||_||_g|_i|_i|_i|_	i|_
i|_i|_i|_
i|_i|_g|_g|_g|_g|_g|_g|_d|_d|_tƒ|_g|_g|_ddl}|jj|ƒ|_g|_ d|_!||_"dS)Nrar)#r—r„r?rAr‘rDÚindirect_targetsÚsubstitution_defsÚsubstitution_namesÚrefnamesÚrefidsÚnameidsÚ	nametypesr˜Ú
footnote_refsÚ
citation_refsÚ
autofootnotesÚautofootnote_refsÚsymbol_footnotesÚsymbol_footnote_refsÚ	footnotesÚ	citationsZautofootnote_startZsymbol_footnote_startrÚ
id_counterÚparse_messagesÚtransform_messagesZdocutils.transformsZ
transformsZTransformerÚtransformerZinclude_logÚ
decorationr&)rr‘rDr
rZdocutilsrrrr„þs>zdocument.__init__cCs|jjƒ}d|d<d|d<|S)zB
        Return dict with unpicklable references removed.
        NrDr+)Ú__dict__r;)rÚstaterrrÚ__getstate__Zs
zdocument.__getstate__NcCs0|dkrddljj}|jƒ}|j|j|ƒƒ|S)z-Return a DOM representation of this document.Nr)r/r0r1r2r§r3)rr0r4rrrr5cs
zdocument.asdomrwcCs>|drZxL|dD]@}|jj||ƒ|j||k	r|jjd|ƒ}|dkr||7}qW|S|jj}|jj}d}d}x®|dD]$}	t|	ƒ}||}|r|||jkr|Pq|W|r¼|jdƒr¼|d}
n0||}
|
jdƒrìd|
dd
…|pæt|j	ƒf}
x4|j
|
d7<d	|
|j
|
f}||jkrîPqîW|dj|ƒ||j|<|S)Nr˜zDuplicate ID: "%s".rwršú%ú-z%s%s-raz%s%drÿ)r˜rÎrDZseverer‘Ú	id_prefixÚauto_id_prefixÚmake_idÚendswithr‡r(r)rr_ÚmsgnodeZsuggested_prefixrürr2r3Zbase_idrµÚprefixrrrÚset_idks>



zdocument.set_idcCsHxB|dD]6}||jkr,|j|||||ƒq
||j|<||j|<q
WdS)aÝ
        `self.nameids` maps names to IDs, while `self.nametypes` maps names to
        booleans representing hyperlink type (True==explicit,
        False==implicit).  This method updates the mappings.

        The following state transition table shows how `self.nameids` ("ids")
        and `self.nametypes` ("types") change with new input (a call to this
        method), and what actions are performed ("implicit"-type system
        messages are INFO/1, and "explicit"-type system messages are ERROR/3):

        ====  =====  ========  ========  =======  ====  =====  =====
         Old State    Input          Action        New State   Notes
        -----------  --------  -----------------  -----------  -----
        ids   types  new type  sys.msg.  dupname  ids   types
        ====  =====  ========  ========  =======  ====  =====  =====
        -     -      explicit  -         -        new   True
        -     -      implicit  -         -        new   False
        None  False  explicit  -         -        new   True
        old   False  explicit  implicit  old      new   True
        None  True   explicit  explicit  new      None  True
        old   True   explicit  explicit  new,old  None  True   [#]_
        None  False  implicit  implicit  new      None  False
        old   False  implicit  implicit  new,old  None  False
        None  True   implicit  implicit  new      None  True
        old   True   implicit  implicit  new      old   True
        ====  =====  ========  ========  =======  ====  =====  =====

        .. [#] Do not clear the name-to-id map or invalidate the old target if
           both old and new targets are external and refer to identical URIs.
           The new target is invalidated regardless.
        ršN)rÚset_duplicate_name_idr)rr_rür6ÚexplicitrµrrrÚset_name_id_map”s
 

zdocument.set_name_id_mapcCsj|j|}|j|}|p||j|<|rê|rÂd}|dk	rŒ|j|}	d|krp|d}
|	drpd|	krp|	d|
krpd}|dkrŒt|	|ƒd|j|<|jj|d||g|d}|dkr¶||7}t||ƒn&||j|<|dk	rè|j|}	t|	|ƒn8|dk	oö|rd|j|<|j|}	t|	|ƒt||ƒ|s<|rf|dk	rf|jjd||g|d}|dkrf||7}dS)NrÚrefuriršraz%Duplicate explicit target name: "%s".)rœÚ	base_nodez%Duplicate implicit target name: "%s".)rrr˜ÚdupnamerDÚsystem_messageÚinfo)rr_rürµr6r:Zold_idZold_explicitr9Úold_noder<rrrrr9»sL











zdocument.set_duplicate_name_idcCs
||jkS)N)r)rrµrrrÚhas_nameåszdocument.has_namecCs"|j||ƒ}|j|||dddS)N)r:)r8r;)rÚtargetr6rürrrÚnote_implicit_targetészdocument.note_implicit_targetcCs"|j||ƒ}|j|||dddS)NT)r:)r8r;)rrCr6rürrrÚnote_explicit_targetíszdocument.note_explicit_targetcCs|jj|dgƒj|ƒdS)NÚrefname)rrÎr)rr_rrrÚnote_refnameñszdocument.note_refnamecCs|jj|dgƒj|ƒdS)Nr)rrÎr)rr_rrrÚ
note_refidôszdocument.note_refidcCs"|jj|ƒ|dr|j|ƒdS)Nrš)rrrG)rrCrrrÚnote_indirect_target÷szdocument.note_indirect_targetcCs|j|ƒdS)N)r8)rrCrrrÚnote_anonymous_targetüszdocument.note_anonymous_targetcCs|j|ƒ|jj|ƒdS)N)r8r"r)rÚfootnoterrrÚnote_autofootnoteÿs
zdocument.note_autofootnotecCs|j|ƒ|jj|ƒdS)N)r8r#r)rÚrefrrrÚnote_autofootnote_refs
zdocument.note_autofootnote_refcCs|j|ƒ|jj|ƒdS)N)r8r$r)rrKrrrÚnote_symbol_footnotes
zdocument.note_symbol_footnotecCs|j|ƒ|jj|ƒdS)N)r8r%r)rrMrrrÚnote_symbol_footnote_refs
z!document.note_symbol_footnote_refcCs|j|ƒ|jj|ƒdS)N)r8r&r)rrKrrrÚ
note_footnotes
zdocument.note_footnotecCs0|j|ƒ|jj|dgƒj|ƒ|j|ƒdS)NrF)r8r rÎrrG)rrMrrrÚnote_footnote_refs
zdocument.note_footnote_refcCs|jj|ƒdS)N)r'r)rÚcitationrrrÚ
note_citationszdocument.note_citationcCs0|j|ƒ|jj|dgƒj|ƒ|j|ƒdS)NrF)r8r!rÎrrG)rrMrrrÚnote_citation_refs
zdocument.note_citation_refcCsft|ƒ}||jkrJ|jjd||d}|dkr6||7}|j|}t||ƒ||j|<||jt|ƒ<dS)Nz-Duplicate substitution definition name: "%s".)r=)Úwhitespace_normalize_namerrDÚerrorr>rÚfully_normalize_name)rZsubdefZdef_namer6rµrZoldnoderrrÚnote_substitution_def s



zdocument.note_substitution_defcCst|ƒ|d<dS)NrF)rV)rZsubrefrFrrrÚnote_substitution_ref/szdocument.note_substitution_refcCs|jj||ƒdS)N)r+Zadd_pending)rÚpendingÚpriorityrrrÚnote_pending2szdocument.note_pendingcCs|jj|ƒdS)N)r)r)rÚmessagerrrÚnote_parse_message5szdocument.note_parse_messagecCs|jj|ƒdS)N)r*r)rr^rrrÚnote_transform_message8szdocument.note_transform_messagecCs$||_|dkr||_n
|d|_dS)Nra)r?rA)rr>ÚoffsetrrrÚnote_source;szdocument.note_sourcecCs*|j|j|jf|jŽ}|j|_|j|_|S)N)rFr‘rDrr>r@)rr÷rrrr;Bs
z
document.copycCsB|js<tƒ|_|jtƒ}|dkr.|j|jƒn|j||jƒ|jS)N)r,rõr	rr")rr!rrrÚget_decorationIs
zdocument.get_decoration)N)Nrw)NN)N)N)N)N)!rrrrgr„r/r5r8r;r9rBrDrErGrHrIrJrLrNrOrPrQrRrTrUrYrZr]r_r`rbr;rcrrrrr(õs<\	

)
'*



r(c@seZdZdS)ÚtitleN)rrrrrrrrdXsrdc@seZdZdS)ÚsubtitleN)rrrrrrrreYsrec@seZdZdS)ÚrubricN)rrrrrrrrfZsrfc@seZdZdS)ÚdocinfoN)rrrrrrrrgasrgc@seZdZdS)ÚauthorN)rrrrrrrrhbsrhc@seZdZdS)ÚauthorsN)rrrrrrrricsric@seZdZdS)ÚorganizationN)rrrrrrrrjdsrjc@seZdZdS)ÚaddressN)rrrrrrrrkesrkc@seZdZdS)ÚcontactN)rrrrrrrrlfsrlc@seZdZdS)ÚversionN)rrrrrrrrmgsrmc@seZdZdS)ÚrevisionN)rrrrrrrrnhsrnc@seZdZdS)ÚstatusN)rrrrrrrroisroc@seZdZdS)ÚdateN)rrrrrrrrpjsrpc@seZdZdS)Ú	copyrightN)rrrrrrrrqksrqc@seZdZdd„Zdd„ZdS)r,cCs6t|jƒst|jdtƒr,|jdtƒƒ|jdS)Nr)rcrKrSÚheaderr")rrrrÚ
get_headertszdecoration.get_headercCs4t|jƒst|jdtƒr*|jtƒƒ|jdS)Nrarÿrÿ)rcrKrSÚfooterr)rrrrÚ
get_footeryszdecoration.get_footerN)rrrrsrurrrrr,rsr,c@seZdZdS)rrN)rrrrrrrrrsrrc@seZdZdS)rtN)rrrrrrrrt€srtc@seZdZdS)ÚsectionN)rrrrrrrrv‡srvc@seZdZdZdS)Útopicaü
    Topics are terminal, "leaf" mini-sections, like block quotes with titles,
    or textual figures.  A topic is just like a section, except that it has no
    subsections, and it doesn't have to conform to section placement rules.

    Topics are allowed wherever body elements (list, table, etc.) are allowed,
    but only at the top level of a section or document.  Topics cannot nest
    inside topics, sidebars, or body elements; you can't have a topic inside a
    table, list, block quote, etc.
    N)rrrrgrrrrrwŠsrwc@seZdZdZdS)ÚsidebaraŸ
    Sidebars are like miniature, parallel documents that occur inside other
    documents, providing related or reference material.  A sidebar is
    typically offset by a border and "floats" to the side of the page; the
    document's main text may flow around it.  Sidebars can also be likened to
    super-footnotes; their content is outside of the flow of the document's
    main text.

    Sidebars are allowed wherever body elements (list, table, etc.) are
    allowed, but only at the top level of a section or document.  Sidebars
    cannot nest inside sidebars, topics, or body elements; you can't have a
    sidebar inside a table, list, block quote, etc.
    N)rrrrgrrrrrx˜srxc@seZdZdS)Ú
transitionN)rrrrrrrry©sryc@seZdZdS)Ú	paragraphN)rrrrrrrrz°srzc@seZdZdS)ÚcompoundN)rrrrrrrr{±sr{c@seZdZdS)Ú	containerN)rrrrrrrr|²sr|c@seZdZdS)Úbullet_listN)rrrrrrrr}³sr}c@seZdZdS)Úenumerated_listN)rrrrrrrr~´sr~c@seZdZdS)Ú	list_itemN)rrrrrrrrµsrc@seZdZdS)Údefinition_listN)rrrrrrrr€¶sr€c@seZdZdS)Údefinition_list_itemN)rrrrrrrr·src@seZdZdS)ÚtermN)rrrrrrrr‚¸sr‚c@seZdZdS)Ú
classifierN)rrrrrrrrƒ¹srƒc@seZdZdS)Ú
definitionN)rrrrrrrr„ºsr„c@seZdZdS)Ú
field_listN)rrrrrrrr…»sr…c@seZdZdS)ÚfieldN)rrrrrrrr†¼sr†c@seZdZdS)Ú
field_nameN)rrrrrrrr‡½sr‡c@seZdZdS)Ú
field_bodyN)rrrrrrrrˆ¾srˆc@seZdZdZdS)ÚoptionrwN)rrrrÅrrrrr‰Ásr‰c@seZdZdd„ZdS)Úoption_argumentcCs|jddƒtj|ƒS)NÚ	delimiterr¢)rÉrr=)rrrrr=Èszoption_argument.astextN)rrrr=rrrrrŠÆsrŠc@seZdZdZdS)Úoption_groupz, N)rrrrÅrrrrrŒÌsrŒc@seZdZdS)Úoption_listN)rrrrrrrrÑsrc@seZdZdZdS)Úoption_list_itemz  N)rrrrÅrrrrrŽÔsrŽc@seZdZdS)Ú
option_stringN)rrrrrrrrÙsrc@seZdZdS)ÚdescriptionN)rrrrrrrrÚsrc@seZdZdS)Ú
literal_blockN)rrrrrrrr‘Ûsr‘c@seZdZdS)Ú
doctest_blockN)rrrrrrrr’Üsr’c@seZdZdS)Ú
math_blockN)rrrrrrrr“Ýsr“c@seZdZdS)Ú
line_blockN)rrrrrrrr”Þsr”c@seZdZdZdS)r@N)rrrr8rrrrr@ásr@c@seZdZdS)Úblock_quoteN)rrrrrrrr•æsr•c@seZdZdS)ÚattributionN)rrrrrrrr–çsr–c@seZdZdS)Ú	attentionN)rrrrrrrr—èsr—c@seZdZdS)ÚcautionN)rrrrrrrr˜ésr˜c@seZdZdS)ÚdangerN)rrrrrrrr™êsr™c@seZdZdS)rWN)rrrrrrrrWësrWc@seZdZdS)Ú	importantN)rrrrrrrršìsršc@seZdZdS)ÚnoteN)rrrrrrrr›ísr›c@seZdZdS)ÚtipN)rrrrrrrrœîsrœc@seZdZdS)ÚhintN)rrrrrrrrïsrc@seZdZdS)ÚwarningN)rrrrrrrržðsržc@seZdZdS)Ú
admonitionN)rrrrrrrrŸñsrŸc@seZdZdS)ÚcommentN)rrrrrrrr òsr c@seZdZdS)Úsubstitution_definitionN)rrrrrrrr¡ósr¡c@seZdZdS)rCN)rrrrrrrrCôsrCc@seZdZdS)rKN)rrrrrrrrKõsrKc@seZdZdS)rSN)rrrrrrrrSösrSc@seZdZdS)ÚlabelN)rrrrrrrr¢÷sr¢c@seZdZdS)ÚfigureN)rrrrrrrr£øsr£c@seZdZdS)ÚcaptionN)rrrrrrrr¤ùsr¤c@seZdZdS)ÚlegendN)rrrrrrrr¥úsr¥c@seZdZdS)ÚtableN)rrrrrrrr¦ûsr¦c@seZdZdS)ÚtgroupN)rrrrrrrr§üsr§c@seZdZdS)ÚcolspecN)rrrrrrrr¨ýsr¨c@seZdZdS)ÚtheadN)rrrrrrrr©þsr©c@seZdZdS)ÚtbodyN)rrrrrrrrªÿsrªc@seZdZdS)ÚrowN)rrrrrrrr«sr«c@seZdZdS)ÚentryN)rrrrrrrr¬sr¬c@s"eZdZdZddd„Zdd„ZdS)r?z‘
    System message element.

    Do not instantiate this class directly; use
    ``document.reporter.info/warning/error/severe()`` instead.
    Nc	Os^|jddƒ}|r$td|ƒ}|f|}ytj||f|ž|ŽWntd|fƒ‚YnXdS)Nrƒrwzsystem_message: children=%r)r#rzr—r„Úprint)rr^rKrrƒÚprrrr„
s

zsystem_message.__init__cCs0|jddƒ}d|d||d|dtj|ƒfS)Nr@rwz%s:%s: (%s/%s) %sr>rbr9)rÉr—r=)rr@rrrr=szsystem_message.astext)N)rrrrgr„r=rrrrr?s
r?c@s,eZdZdZddd„Zd
dd	„Zd
d„ZdS)r[aF
    The "pending" element is used to encapsulate a pending operation: the
    operation (transform), the point at which to apply it, and any data it
    requires.  Only the pending operation's location within the document is
    stored in the public document tree (by the "pending" object itself); the
    operation and its data are stored in the "pending" object's internal
    instance attributes.

    For example, say you want a table of contents in your reStructuredText
    document.  The easiest way to specify where to put it is from within the
    document, with a directive::

        .. contents::

    But the "contents" directive can't do its work until the entire document
    has been parsed and possibly transformed to some extent.  So the directive
    code leaves a placeholder behind that will trigger the second phase of its
    processing, something like this::

        <pending ...public attributes...> + internal attributes

    Use `document.note_pending()` so that the
    `docutils.transforms.Transformer` stage of processing can run all pending
    transforms.
    NrwcOs(tj||f|ž|Ž||_|p i|_dS)N)r—r„Ú	transformÚdetails)rr¯r°rƒrKrrrrr„:s
zpending.__init__ú    rcs
dd|jj|jjfdg}t|jjƒƒ}x¸|D]°\}}t|tƒrp|jdd|fƒ|j	dd„|j
ƒjƒDƒƒq.|rÊt|tƒrÊt|dtƒrÊ|jdd|fƒx>|D] }|j	d	d„|j
ƒjƒDƒƒq¤Wq.|jd
d||fƒq.Wt
j
|ˆˆƒdj‡‡fdd„|DƒƒS)Nz.. internal attributes:z     .transform: %s.%sz     .details:z%7s%s:rwcSsg|]}dd|f‘qS)z%9s%srwr)rr@rrrrŽOsz#pending.pformat.<locals>.<listcomp>rcSsg|]}dd|f‘qS)z%9s%srwr)rr@rrrrŽUsz	%7s%s: %rcsg|]}dˆˆ|f‘qS)z	    %s%s
r)rr@)r8r9rrrŽZs)r¯rrrÈr°rŸrSr%rr r:r’rr—ry)rr8r9Z	internalsr°r¹r*r¤r)r8r9rr:Es(




zpending.pformatcCs6|j|j|j|jf|jŽ}|j|_|j|_|j|_|S)N)rFr¯r°rƒrr&r>r@)rr÷rrrr;]szpending.copy)Nrw)r±r)rrrrgr„r:r;rrrrr[s



r[c@seZdZdZdS)Úrawz@
    Raw data that is to be passed untouched to the Writer.
    N)rrrrgrrrrr²fsr²c@seZdZdS)ÚemphasisN)rrrrrrrr³ssr³c@seZdZdS)ÚstrongN)rrrrrrrr´tsr´c@seZdZdS)ÚliteralN)rrrrrrrrµusrµc@seZdZdS)Ú	referenceN)rrrrrrrr¶vsr¶c@seZdZdS)Úfootnote_referenceN)rrrrrrrr·wsr·c@seZdZdS)Úcitation_referenceN)rrrrrrrr¸xsr¸c@seZdZdS)Úsubstitution_referenceN)rrrrrrrr¹ysr¹c@seZdZdS)Útitle_referenceN)rrrrrrrrºzsrºc@seZdZdS)ÚabbreviationN)rrrrrrrr»{sr»c@seZdZdS)ÚacronymN)rrrrrrrr¼|sr¼c@seZdZdS)ÚsuperscriptN)rrrrrrrr½}sr½c@seZdZdS)Ú	subscriptN)rrrrrrrr¾~sr¾c@seZdZdS)ÚmathN)rrrrrrrr¿sr¿c@seZdZdd„ZdS)ÚimagecCs|jddƒS)NZaltrw)rÉ)rrrrr=„szimage.astextN)rrrr=rrrrrÀ‚srÀc@seZdZdS)ÚinlineN)rrrrrrrrÁˆsrÁc@seZdZdS)ÚproblematicN)rrrrrrrr‰srÂc@seZdZdS)Ú	generatedN)rrrrrrrrÊsrÃa<
    Text
    abbreviation acronym address admonition attention attribution author
        authors
    block_quote bullet_list
    caption caution citation citation_reference classifier colspec comment
        compound contact container copyright
    danger date decoration definition definition_list definition_list_item
        description docinfo doctest_block document
    emphasis entry enumerated_list error
    field field_body field_list field_name figure footer
        footnote footnote_reference
    generated
    header hint
    image important inline
    label legend line line_block list_item literal literal_block
    math math_block
    note
    option option_argument option_group option_list option_list_item
        option_string organization
    paragraph pending problematic
    raw reference revision row rubric
    section sidebar status strong subscript substitution_definition
        substitution_reference subtitle superscript system_message
    table target tbody term tgroup thead tip title title_reference topic
        transition
    version
    warningc@s<eZdZdZfZdd„Zdd„Zdd„Zdd	„Zd
d„Z	dS)
ÚNodeVisitoraŽ
    "Visitor" pattern [GoF95]_ abstract superclass implementation for
    document tree traversals.

    Each node class has corresponding methods, doing nothing by
    default; override individual methods for specific and useful
    behaviour.  The `dispatch_visit()` method is called by
    `Node.walk()` upon entering a node.  `Node.walkabout()` also calls
    the `dispatch_departure()` method before exiting a node.

    The dispatch methods call "``visit_`` + node class name" or
    "``depart_`` + node class name", resp.

    This is a base class for visitors whose ``visit_...`` & ``depart_...``
    methods should be implemented for *all* node types encountered (such as
    for `docutils.writers.Writer` subclasses).  Unimplemented methods will
    raise exceptions.

    For sparse traversals, where only certain node types are of interest, use
    subclass `SparseNodeVisitor` instead.  When (mostly or entirely) uniform
    processing is desired, subclass `GenericNodeVisitor`.

    .. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of
       Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA,
       1995.
    cCs
||_dS)N)r()rr(rrrr„×szNodeVisitor.__init__cCs:|jj}t|d||jƒ}|jjjd|j|fƒ||ƒS)zª
        Call self."``visit_`` + node class name" with `node` as
        parameter.  If the ``visit_...`` method does not exist, call
        self.unknown_visit.
        Úvisit_z;docutils.nodes.NodeVisitor.dispatch_visit calling %s for %s)rFrrûÚ
unknown_visitr(rDrE)rr_Ú	node_nameÚmethodrrrrGÚszNodeVisitor.dispatch_visitcCs:|jj}t|d||jƒ}|jjjd|j|fƒ||ƒS)z°
        Call self."``depart_`` + node class name" with `node` as
        parameter.  If the ``depart_...`` method does not exist, call
        self.unknown_departure.
        Údepart_z?docutils.nodes.NodeVisitor.dispatch_departure calling %s for %s)rFrrûÚunknown_departurer(rDrE)rr_rÇrÈrrrrRçszNodeVisitor.dispatch_departurecCs2|jjjs|jj|jkr.td|j|jjfƒ‚dS)zk
        Called when entering unknown `Node` types.

        Raise an exception unless overridden.
        z!%s visiting unknown node type: %sN)r(r‘Ústrict_visitorrFrÚoptionalr7)rr_rrrrÆôs

zNodeVisitor.unknown_visitcCs2|jjjs|jj|jkr.td|j|jjfƒ‚dS)zi
        Called before exiting unknown `Node` types.

        Raise exception unless overridden.
        z"%s departing unknown node type: %sN)r(r‘rËrFrrÌr7)rr_rrrrÊs

zNodeVisitor.unknown_departureN)
rrrrgrÌr„rGrRrÆrÊrrrrrÄ°s


rÄc@seZdZdZdS)ÚSparseNodeVisitora
    Base class for sparse traversals, where only certain node types are of
    interest.  When ``visit_...`` & ``depart_...`` methods should be
    implemented for *all* node types (such as for `docutils.writers.Writer`
    subclasses), subclass `NodeVisitor` instead.
    N)rrrrgrrrrrÍ
srÍc@s eZdZdZdd„Zdd„ZdS)ÚGenericNodeVisitora˜
    Generic "Visitor" abstract superclass, for simple traversals.

    Unless overridden, each ``visit_...`` method calls `default_visit()`, and
    each ``depart_...`` method (when using `Node.walkabout()`) calls
    `default_departure()`. `default_visit()` (and `default_departure()`) must
    be overridden in subclasses.

    Define fully generic visitors by overriding `default_visit()` (and
    `default_departure()`) only. Define semi-generic visitors by overriding
    individual ``visit_...()`` (and ``depart_...()``) methods also.

    `NodeVisitor.unknown_visit()` (`NodeVisitor.unknown_departure()`) should
    be overridden for default behavior.
    cCst‚dS)z)Override for generic, uniform traversals.N)r7)rr_rrrÚ
default_visit)sz GenericNodeVisitor.default_visitcCst‚dS)z)Override for generic, uniform traversals.N)r7)rr_rrrÚdefault_departure-sz$GenericNodeVisitor.default_departureN)rrrrgrÏrÐrrrrrÎsrÎcCs|j|ƒdS)N)rÏ)rr_rrrÚ_call_default_visit1srÑcCs|j|ƒdS)N)rÐ)rr_rrrÚ_call_default_departure4srÒcCsdS)Nr)rr_rrrÚ_nop7srÓcCsRxL|D]D}ttd|tƒttd|tƒttd|tƒttd|tƒqWdS)z%Save typing with dynamic assignments:rÅrÉN)ÚsetattrrÎrÑrÒrÍrÓ)ršÚ_namerrrÚ_add_node_class_names:s

rÖc@s0eZdZdZdd„Zdd„Zdd„Zdd	„Zd
S)ÚTreeCopyVisitorzQ
    Make a complete copy of a tree or branch, including element attributes.
    cCstj||ƒg|_g|_dS)N)rÎr„Úparent_stackr')rr(rrrr„KszTreeCopyVisitor.__init__cCs
|jdS)Nr)r')rrrrÚ
get_tree_copyPszTreeCopyVisitor.get_tree_copycCs,|jƒ}|jj|ƒ|jj|jƒ||_dS)z9Copy the current node, and make it the new acting parent.N)r;r'rrØ)rr_ZnewnoderrrrÏSszTreeCopyVisitor.default_visitcCs|jjƒ|_dS)z#Restore the previous acting parent.N)rØr#r')rr_rrrrÐZsz!TreeCopyVisitor.default_departureN)rrrrgr„rÙrÏrÐrrrrr×Es
r×c@seZdZdZdS)ÚTreePruningExceptionz÷
    Base class for `NodeVisitor`-related tree pruning exceptions.

    Raise subclasses from within ``visit_...`` or ``depart_...`` methods
    called from `Node.walk()` and `Node.walkabout()` tree traversals to prune
    the tree traversed.
    N)rrrrgrrrrrÚ_srÚc@seZdZdZdS)rHz…
    Do not visit any children of the current node.  The current node's
    siblings and ``depart_...`` method are not affected.
    N)rrrrgrrrrrHlsrHc@seZdZdZdS)rMz
    Do not visit any more siblings (to the right) of the current node.  The
    current node's children and its ``depart_...`` method are not affected.
    N)rrrrgrrrrrMvsrMc@seZdZdZdS)rIzq
    Do not visit the current node's children, and do not call the current
    node's ``depart_...`` method.
    N)rrrrgrrrrrI€srIc@seZdZdZdS)rJz
    Do not call the current node's ``depart_...`` method.  The current node's
    children and siblings are not affected.
    N)rrrrgrrrrrJŠsrJc@seZdZdZdS)Ú	NodeFoundz¥
    Raise to indicate that the target of a search has been found.  This
    exception must be caught by the client; it is not caught by the traversal
    code.
    N)rrrrgrrrrrÛ”srÛc@seZdZdZdS)rNa=
    Stop the traversal alltogether.  The current node's ``depart_...`` method
    is not affected.  The parent nodes ``depart_...`` methods are also called
    as usual.  No other nodes are visited.  This is an alternative to
    NodeFound that does not cause exception handling to trickle up to the
    caller.
    N)rrrrgrrrrrNŸsrNcCsr|jƒ}t|tƒs|jƒ}|jtƒ}|jtƒ}tjd|ƒj	ddƒjdƒ}t
jddj|j
ƒƒƒ}tjd|ƒ}t|ƒS)aû
    Convert `string` into an identifier and return it.

    Docutils identifiers will conform to the regular expression
    ``[a-z](-?[a-z0-9]+)*``.  For CSS compatibility, identifiers (the "class"
    and "id" attributes) should have no underscores, colons, or periods.
    Hyphens may be used.

    - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens:

          ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
          followed by any number of letters, digits ([0-9]), hyphens ("-"),
          underscores ("_"), colons (":"), and periods (".").

    - However the `CSS1 spec`_ defines identifiers based on the "name" token,
      a tighter interpretation ("flex" tokenizer notation; "latin1" and
      "escape" 8-bit characters have been replaced with entities)::

          unicode     \[0-9a-f]{1,4}
          latin1      [&iexcl;-&yuml;]
          escape      {unicode}|\[ -~&iexcl;-&yuml;]
          nmchar      [-a-z0-9]|{latin1}|{escape}
          name        {nmchar}+

    The CSS1 "nmchar" rule does not include underscores ("_"), colons (":"),
    or periods ("."), therefore "class" and "id" attributes should not contain
    these characters. They should be replaced with hyphens ("-"). Combined
    with HTML's requirements (the first character must be a letter; no
    "unicode", "latin1", or "escape" characters), this results in the
    ``[a-z](-?[a-z0-9]+)*`` pattern.

    .. _HTML 4.01 spec: http://www.w3.org/TR/html401
    .. _CSS1 spec: http://www.w3.org/TR/REC-CSS1
    ZNFKDroÚignorer1r¢rw)r rSr,ÚdecodeÚ	translateÚ_non_id_translate_digraphsÚ_non_id_translateÚunicodedataÚ	normalizer-Ú
_non_id_charsÚsubryrzÚ_non_id_at_endsr¿)Ústringrürrrr4¬s#


r4z
[^a-z0-9]+z^[-0-9]+|-+$ÚoÚdÚhrÓÚlÚtÚbr­ÚfÚkr¬r®ÚyÚzÚgÚjrqÚeÚqÚr)!éøii'i1iBigi€iƒiˆiŒi’i™išiži¥i«i­i´i¶iåi%i4i5i6i7i<i?i@iGiIiKiMiOÚszZaeZoeÚdbZqp)éßéæiSi8i9cCs&|dj|ƒ|dj|ƒd|_dS)Nr›ršra)rrÔrú)r_rµrrrr>
	sr>cCsdj|jƒjƒƒS)z.Return a case- and whitespace-normalized name.r¢)ryr rz)rµrrrrX	srXcCsdj|jƒƒS)z$Return a whitespace-normalized name.r¢)ryrz)rµrrrrV	srVcCs|jddƒjddƒS)zDEscape string values that are elements of a list, for serialization.rtz\\r¢z\ )rx)r*rrrr£	sr£cCsd|S)zQuote attributes for pseudo-xmlz"%s"r)r*rrrr²	sr²)rr)rr)FF)«rgÚ
__future__rÚcollectionsrZ
__docformat__rjÚosÚrer	rárkr¿r,r¸rrÚobjectr%rmrrr}r~r—rrrrrr	r
rrr
rrrrrrrrrrrr(rdrerfrgrhrirjrkrlrmrnrorprqr,rrrtrvrwrxryrzr{r|r}r~rr€rr‚rƒr„r…r†r‡rˆr‰rŠrŒrrŽrrr‘r’r“r”r@r•r–r—r˜r™rWršr›rœrržrŸr r¡rCrKrSr¢r£r¤r¥r¦r§r¨r©rªr«r¬r?r[r²r³r´rµr¶r·r¸r¹rºr»r¼r½r¾r¿rÀrÁrÂrÃrzZnode_class_namesrÄrÍrÎrÑrÒrÓrÖr×Ú	ExceptionrÚrHrMrIrJrÛrNr4Úcompilerãråràrßr>rXrVr£r²rrrrÚ<module>s¤ )	S

	e
H
"
]






1