allura
修訂 | 11a57546aa1bd9c195fe4738458e31ed049defe1 (tree) |
---|---|
時間 | 2012-06-14 04:13:57 |
作者 | Dave Brondsema <dbrondsema@geek...> |
Commiter | Yaroslav Luzin |
[#4254] disable [plain] handling for HTML import for now; improved [plain] insertion for plaintext
@@ -168,17 +168,25 @@ class RssFeedsCommand(base.BlogCommand): | ||
168 | 168 | content = u'' |
169 | 169 | for ct in e.content: |
170 | 170 | if ct.type != 'text/html': |
171 | - content = u"%s<p>%s</p>" % (content, ct.value) | |
171 | + content += '[plain]%s[/plain]' % ct.value | |
172 | 172 | else: |
173 | - content = content + ct.value | |
173 | + if False: | |
174 | + # FIXME: disabled until https://sourceforge.net/p/allura/tickets/4345 | |
175 | + # because the bad formatting from [plain] is worse than bad formatting from unintentional markdown syntax | |
176 | + parser = MDHTMLParser() | |
177 | + parser.feed(ct.value) | |
178 | + parser.close() # must be before using the result_doc | |
179 | + markdown_content = html2text.html2text(parser.result_doc, baseurl=e.link) | |
180 | + else: | |
181 | + markdown_content = html2text.html2text(ct.value, baseurl=e.link) | |
182 | + | |
183 | + content += markdown_content | |
174 | 184 | else: |
175 | - content = e.summary | |
185 | + content = '[plain]%s[/plain]' % getattr(e, 'summary', | |
186 | + getattr(e, 'subtitle', | |
187 | + getattr(e, 'title'))) | |
176 | 188 | |
177 | - content = u'%s <a href="%s">link</a>' % (content, e.link) | |
178 | - parser = MDHTMLParser() | |
179 | - parser.feed(content) | |
180 | - parser.close() | |
181 | - content = html2text.html2text(parser.result_doc, e.link) | |
189 | + content += u' [link](%s)' % e.link | |
182 | 190 | |
183 | 191 | updated = datetime.utcfromtimestamp(mktime(e.updated_parsed)) |
184 | 192 |