new pandoc function with a bit more sanity on usage and autopep cleanup
Peter Molnar hello@petermolnar.eu
Fri, 29 Jun 2018 11:40:22 +0200
4 files changed,
77 insertions(+),
72 deletions(-)
M
archive.py
→
archive.py
@@ -209,6 +209,7 @@ if not fav.exists:
fav.run() # fav.fix_extension() + class TumblrFavs(Favs): url = 'https://api.tumblr.com/v2/user/likes'@@ -516,9 +517,9 @@ self.photo.get('date_faved',
arrow.utcnow().timestamp ) ), - 'title': '%s' % shared.Pandoc('plain').convert( + 'title': '%s' % shared.PandocNG( self.photo.get('title', '') - ).rstrip(), + ).txt.rstrip(), 'favorite-of': self.url, 'tags': self.photo.get('tags', '').split(' '), 'geo': {@@ -533,9 +534,9 @@ ),
}, } - self.content = shared.Pandoc('plain').convert( + self.content = shared.PandocNG( self.photo.get('description', {}).get('_content', '') - ) + ).txt self.fix_extension() self.write_exif()@@ -581,7 +582,9 @@ self.fav.get('published_time',
arrow.utcnow().timestamp ) ), - 'title': '%s' % shared.Pandoc('plain').convert(self.title).rstrip(), + 'title': '%s' % shared.PandocNG( + self.title + ).txt.rstrip(), 'favorite-of': self.url, 'tags': [t.get('tag_name') for t in self.fav.get('meta', {}).get('tags', [])], 'author': {@@ -590,7 +593,7 @@ 'url': 'https://%s.deviantart.com' % (self.author),
}, } c = "%s" % self.fav.get('meta', {}).get('description', '') - self.content = shared.Pandoc('plain').convert(c) + self.content = shared.PandocNG(c).txt self.fix_extension() self.write_exif()
M
envelope.py
→
envelope.py
@@ -29,7 +29,7 @@ import os
import re import smtplib import logging -from shared import Pandoc +from shared import PandocNG class Letter(object):@@ -54,7 +54,7 @@ self.headers = {}
@property def _html(self): - return Pandoc().convert(self.text) + return PandocNG(self.text).html @property def _tmpl(self):
M
nasg.py
→
nasg.py
@@ -543,7 +543,7 @@
@property def is_old(self): tdiff = arrow.utcnow() - arrow.get(self.mtime) - return (tdiff.days > 2*365) + return (tdiff.days > 2 * 365) @property def htmlfile(self):@@ -729,9 +729,8 @@ return body
@property def html(self): - html = "%s" % (self.body) - - return shared.Pandoc().convert(html) + # return shared.Pandoc().convert(html) + return shared.PandocNG("%s" % (self.body)).html @property def title(self):@@ -752,7 +751,9 @@ s = self.meta.get('summary', '')
if not s: return s if not hasattr(self, '_summary'): - self._summary = shared.Pandoc().convert(s) + #self._summary = shared.Pandoc().convert(s) + self._summary = shared.PandocNG(s).html + return self._summary @property@@ -1162,11 +1163,11 @@ # the actual limit
# 2.39 is the wide angle cinematic view: anything wider, than that # is panorama land if ratio > 2.4 and not crop: - size = int(size*0.6) + size = int(size * 0.6) horizontal = not horizontal if (horizontal and not crop) \ - or (not horizontal and crop): + or (not horizontal and crop): w = size h = int(float(size / width) * height) else:@@ -1310,8 +1311,9 @@ return arrow.get(self.meta.get('date'))
@property def html(self): - html = "%s" % (self.content) - return shared.Pandoc().convert(html) + #html = "%s" % (self.content) + # return shared.Pandoc().convert(html) + return shared.PandocNG("%s" % (self.content)).html @property def target(self):@@ -1351,7 +1353,8 @@ if t != 'webmention':
self._type = '★' if len(self.content): - maybe = shared.Pandoc('plain').convert(self.content) + #maybe = shared.Pandoc('plain').convert(self.content) + maybe = shared.PandocNG(self.content).txt if maybe in UNICODE_EMOJI: self._type = maybe return self._type@@ -1507,7 +1510,8 @@ elif 'text' in self._source.get('data').get('content'):
what = self._source.get('data').get('content').get('text') else: return '' - return shared.Pandoc('html').convert(what) + # return shared.Pandoc('html').convert(what) + return shared.PandocNG(what).html @property def fname(self):