@@ -125,6 +125,7 @@ def remove_whitespace(string, leading=False, trailing=False):
125125
126126 # Replace new line characters and absorb any surrounding space.
127127 string = re .sub (r'\s*\n\s*' , ' ' , string )
128+ # TODO need some way to get rid of extra spaces in e.g. text <span> </span> text
128129 return re .sub (r'\s+' , ' ' , string )
129130
130131def delete_paragraph (paragraph ):
@@ -363,7 +364,17 @@ def handle_link(self, href, text):
363364 # Create sub-run
364365 subrun = self .paragraph .add_run ()
365366 rPr = docx .oxml .shared .OxmlElement ('w:rPr' )
366- rPr .style = 'Hyperlink'
367+
368+ # add default color
369+ c = docx .oxml .shared .OxmlElement ('w:color' )
370+ c .set (docx .oxml .shared .qn ('w:val' ), "0000EE" )
371+ rPr .append (c )
372+
373+ # add underline
374+ u = docx .oxml .shared .OxmlElement ('w:u' )
375+ u .set (docx .oxml .shared .qn ('w:val' ), 'single' )
376+ rPr .append (u )
377+
367378 subrun ._r .append (rPr )
368379 subrun ._r .text = text
369380
@@ -489,15 +500,8 @@ def handle_data(self, data):
489500
490501 # Only remove white space if we're not in a pre block.
491502 if 'pre' not in self .tags :
492-
493- args = {}
494-
495- # In a code block we want to strip leading and trailing new lines and white space.
496- # Without this we would have a leading space in the code block.
497- if 'code' in self .tags :
498- args ['leading' ] = True
499- args ['trailing' ] = True
500- data = remove_whitespace (data , ** args )
503+ # remove leading and trailing whitespace in all instances
504+ data = remove_whitespace (data , True , True )
501505
502506 if not self .paragraph :
503507 self .paragraph = self .doc .add_paragraph ()
0 commit comments