diff --git a/server/aap/publish/formatters/aap_ipnews_formatter.py b/server/aap/publish/formatters/aap_ipnews_formatter.py index e9763b513..a02e5cc1a 100644 --- a/server/aap/publish/formatters/aap_ipnews_formatter.py +++ b/server/aap/publish/formatters/aap_ipnews_formatter.py @@ -41,19 +41,20 @@ def format(self, article, subscriber, codes=None): elif article.get(FORMAT, FORMATS.HTML) == FORMATS.HTML: text = StringIO() for p in soup.findAll('p'): - text.write('\x19\r\n') + text.write(' ') ptext = p.get_text('\n') for l in ptext.split('\n'): if len(l) > 80: text.write(textwrap.fill(l, 80).replace('\n', ' \r\n')) else: text.write(l + ' \r\n') + text.write('\x19\r\n') body = text.getvalue().replace('\'', '\'\'') # if this is the first take and we have a dateline inject it if self.is_first_part(article) and 'dateline' in article and 'text' in article.get('dateline', {}): - if body.startswith('\x19\r\n'): - body = '\x19\r\n{} {}'.format(article.get('dateline').get('text').replace('\'', '\'\''), - body[3:]) + if body.startswith(' '): + body = ' {} {}'.format(article.get('dateline').get('text').replace('\'', '\'\''), + body[3:]) odbc_item['article_text'] = body odbc_item['texttab'] = 'x' diff --git a/server/aap/publish/formatters/aap_ipnews_formatter_test.py b/server/aap/publish/formatters/aap_ipnews_formatter_test.py index 94dc51bc9..d907807c4 100644 --- a/server/aap/publish/formatters/aap_ipnews_formatter_test.py +++ b/server/aap/publish/formatters/aap_ipnews_formatter_test.py @@ -117,8 +117,8 @@ def testIPNewsHtmlToText(self): seq, item = f.format(article, subscriber)[0] item = json.loads(item) - expected = '\r\nThe story body line 1 \r\nLine 2 \r\n\r\nabcdefghi abcdefghi abcdefghi abcdefghi ' \ - 'abcdefghi abcdefghi abcdefghi abcdefghi \r\n\r\nMORE' + expected = ' The story body line 1 \r\nLine 2 \r\n\r\n abcdefghi abcdefghi abcdefghi abcdefghi ' \ + 'abcdefghi abcdefghi abcdefghi abcdefghi \r\n\r\n\r\nMORE' self.assertEqual(item['article_text'], expected) def testLastTake(self): @@ -150,9 +150,8 @@ def testLastTake(self): f = AAPIpNewsFormatter() seq, item = f.format(article, subscriber)[0] item = json.loads(item) - - expected = '\r\nThe story body line 1 \r\nLine 2 \r\n\r\nabcdefghi abcdefghi abcdefghi abcdefghi ' \ - 'abcdefghi abcdefghi abcdefghi abcdefghi \r\n\r\nAAP' + expected = ' The story body line 1 \r\nLine 2 \r\n\r\n abcdefghi abcdefghi abcdefghi abcdefghi ' \ + 'abcdefghi abcdefghi abcdefghi abcdefghi \r\n\r\n\r\nAAP' self.assertEqual(item['article_text'], expected) def testMultipleCategories(self):