<commit_before>===========================
Article HTML Representation
===========================

The HTML representation ... 

Create an article firs::

  >>> import StringIO
  >>> from zeit.content.article.article import Article
  >>> source = '''\
  ... <article>
  ...   <head/>
  ...   <body>
  ...     <title>Title</title>
  ...     <p>A paragraph</p>
  ...     <p>Another <em>paragraph</em></p>
  ...     <teaser/>
  ...   </body>
  ... </article>'''
  >>> article = Article(xml_source=StringIO.StringIO(source))


Get the HTML representation::

  >>> print article.html
  <p>A paragraph</p>
  <p>Another <em>paragraph</em></p>


The original article xml is of course unmodifed so far::

  >>> import lxml.etree
  >>> print lxml.etree.tostring(article.xml, pretty_print=True)
  <article>
    <head/>
    <body>
      <title>Title</title>
      <p>A paragraph</p>
      <p>Another <em>paragraph</em></p>
      <teaser/>
    </body>
  </article>


Now for something more complex, the intertitle::


  >>> from zeit.content.article.article import Article
  >>> source = '''\
  ... <article>
  ...   <head/>
  ...   <body>
  ...     <title>Title</title>
  ...     <p>A paragraph</p>
  ...     <intertitle>Paragraphs are nice</intertitle>  
  ...     <p>Another <em>paragraph</em></p>
  ...     <teaser/>
  ...   </body>
  ... </article>'''
  >>> article = Article(xml_source=StringIO.StringIO(source))

In the html `intertitle` becomes an `h3`::
  >>> print article.html
  <p>A paragraph</p>
  <h3>Paragraphs are nice</h3>
  <p>Another <em>paragraph</em></p>


Now we change the HTML and see the reflection in the article XML. The `h3` in
the html becomes an `intertitle` again::

  >>> article.html = """\
  ...   <p>A paragraph with more <em>markup</em></p>
  ...   <h3>Paragraphs are nice</h3>
  ...   <p>Another <em>paragraph</em></p>
  ...   <p>Bla bla bla</p>
  ... """

  >>> print lxml.etree.tostring(article.xml, pretty_print=True)
  <article>
    <head/>
    <body>
      <title>Title</title>
      <teaser/>
      <p>A paragraph with more <em>markup</em></p>
      <intertitle>Paragraphs are nice</intertitle>
      <p>Another <em>paragraph</em></p>
      <p>Bla bla bla</p>
    </body>
  </article>
<commit_msg>doctest syntax<commit_after>===========================
Article HTML Representation
===========================

The HTML representation ... 

Create an article firs:

>>> import StringIO
>>> from zeit.content.article.article import Article
>>> source = '''\
... <article>
...   <head/>
...   <body>
...     <title>Title</title>
...     <p>A paragraph</p>
...     <p>Another <em>paragraph</em></p>
...     <teaser/>
...   </body>
... </article>'''
>>> article = Article(xml_source=StringIO.StringIO(source))


Get the HTML representation:

>>> print article.html
<p>A paragraph</p>
<p>Another <em>paragraph</em></p>


The original article xml is of course unmodifed so far:

>>> import lxml.etree
>>> print lxml.etree.tostring(article.xml, pretty_print=True)
<article>
  <head/>
  <body>
    <title>Title</title>
    <p>A paragraph</p>
    <p>Another <em>paragraph</em></p>
    <teaser/>
  </body>
</article>


Now for something more complex, the intertitle:


>>> from zeit.content.article.article import Article
>>> source = '''\
... <article>
...   <head/>
...   <body>
...     <title>Title</title>
...     <p>A paragraph</p>
...     <intertitle>Paragraphs are nice</intertitle>  
...     <p>Another <em>paragraph</em></p>
...     <teaser/>
...   </body>
... </article>'''
>>> article = Article(xml_source=StringIO.StringIO(source))

In the html `intertitle` becomes an `h3`:
>>> print article.html
<p>A paragraph</p>
<h3>Paragraphs are nice</h3>
<p>Another <em>paragraph</em></p>


Now we change the HTML and see the reflection in the article XML. The `h3` in
the html becomes an `intertitle` again:

>>> article.html = """\
...   <p>A paragraph with more <em>markup</em></p>
...   <h3>Paragraphs are nice</h3>
...   <p>Another <em>paragraph</em></p>
...   <p>Bla bla bla</p>
... """

>>> print lxml.etree.tostring(article.xml, pretty_print=True)
<article>
  <head/>
  <body>
    <title>Title</title>
    <teaser/>
    <p>A paragraph with more <em>markup</em></p>
    <intertitle>Paragraphs are nice</intertitle>
    <p>Another <em>paragraph</em></p>
    <p>Bla bla bla</p>
  </body>
</article>

{'fraction_non_alphanumeric': 0.2223249364455743, 'fraction_numerical': 0.0027732840305061245, 'mean_word_length': 2.8920863309352516, 'pattern_counts': {'":': 0, '<': 183, '<?xml version=': 0, '>': 261, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6418343', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1504, 'n_words': 341}