title: How to Apply Word Styles to Richtext Object? (docxtpl library)
body: <p>I'm currently trying to generate a word document using the docxtpl. However, i cannot work out how to add a word style to the Richtext object when the style name includes a space, as the style doesn't get applied within the word document. In other cases where the style is named using a single word, it works fine.
  Here is my current code:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  from docxtpl import DocxTemplate, RichText
  
  html = "&lt;html&gt;&lt;body&gt;&lt;p&gt;&lt;p&gt;I am a paragraph generated by python.&lt;/p&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;List 1 item 1&lt;/li&gt;&lt;li&gt;List 1 item " \
     "2&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Example below:&lt;/p&gt;&lt;li&gt;List 2 item 1&lt;/li&gt;&lt;li&gt;List 2 item 1&lt;/li&gt;&lt;p&gt;End paragraph&lt;/p&gt;&lt;/body&gt;&lt;/html&gt; "
  
  
  def main():
      soup = BeautifulSoup(html, 'html.parser').find_all()
      rt = RichText()
      for tag in soup:
          if tag.name == 'p' and tag.parent.name != 'p':
              print tag.text
              rt.add(tag.text + "\n\n")
          elif tag.name == 'li' and tag.parent.name != 'li':
              rt.add(tag.text + "\n", style='Subtle Reference')
  
      output_data = {"data": rt}
      tpl = DocxTemplate('template.docx')
      tpl.render(output_data)
      tpl.save('output.docx')
  </code></pre>
  
  <p>Jinja code within word document:</p>
  
  <pre><code>{{r data}}
  </code></pre>
  
  <p>I've created an issue on gitlab with this, but was wondering if anyone had used this library before and had any good work arounds?</p>