@@ -69,12 +69,13 @@ def w_element(name, content=(), **attrs):
69
69
return e
70
70
71
71
class Paragraph (list ):
72
- __slots__ = ["pStyle" , "numId" , "ilvl" ]
73
- def __init__ (self , runs = (), pStyle = None , numId = None , ilvl = None ):
72
+ __slots__ = ["pStyle" , "numId" , "ilvl" , "spacingAfter" ]
73
+ def __init__ (self , runs = (), pStyle = None , numId = None , ilvl = None , spacingAfter = None ):
74
74
list .__init__ (self , runs )
75
75
self .pStyle = pStyle
76
76
self .numId = numId
77
77
self .ilvl = ilvl
78
+ self .spacingAfter = spacingAfter
78
79
79
80
def to_etree (self ):
80
81
content = []
@@ -87,6 +88,9 @@ def to_etree(self):
87
88
w_element (u"numId" , val = str (self .numId )),
88
89
w_element (u"ilvl" , val = str (self .ilvl ))
89
90
]))
91
+ if self .spacingAfter is not None :
92
+ pPr_content .append (w_element (u"spacing" , after = str (self .spacingAfter )))
93
+ pPr_content .append (w_element (u"contextualSpacing" ))
90
94
if pPr_content :
91
95
pPr = w_element (u"pPr" , pPr_content )
92
96
content .append (pPr )
@@ -243,9 +247,14 @@ def convert_block(e, numId=None, list_level=0):
243
247
else :
244
248
pStyle = "Alg4"
245
249
246
- for child in e :
247
- for p in convert_li (child , numId , pStyle , list_level = list_level + 1 ):
248
- yield p
250
+ # Put extra spacing on the last list item.
251
+ paras = [p for child in e
252
+ for p in convert_li (child , numId , pStyle , list_level = list_level + 1 )]
253
+ if tag == 'ol' and list_level == 0 and paras :
254
+ paras [- 1 ].spacingAfter = 240
255
+ for p in paras :
256
+ yield p
257
+
249
258
elif tag == "blockquote" :
250
259
if list_level != 0 :
251
260
raise Exception ("can't convert a blockquote inside a list" )
0 commit comments