def diff_processtext(text): """ Prepares the supplied post text to be diff'ed. """ from snapboard.templatetags.extras import render_filter texth = render_filter(text) # -> html textl = re.findall(r'<[^>]*?>|[^<]+', texth) # -> tags&text out = [] for item in textl: # -> tags & words. if item.startswith("<"): out.append(item) else: #out += item.split() # Extra spaces? #out += re.findall(r'[ ]+|[^ ]+', item) out += list(item) # by-symbol diff o_O return out
def save(self, force_insert=False, force_update=False): # ? huh? #_log.debug('user = %s, ip = %s' % (threadlocals.get_current_ip(), # threadlocals.get_current_user())) # hack to disallow admin setting arbitrary users to posts if getattr(self, 'user_id', None) is None: self.user_id = threadlocals.get_current_user().id # disregard any modifications to ip address self.ip = threadlocals.get_current_ip() # ! XXX: Not really appropriate to do it here?.. from snapboard.templatetags.extras import render_filter self.texth = render_filter(self.text) super(Post, self).save(force_insert, force_update) ## Update the thread-local id afterwards. self.update_lid()
def _sanitize(text): return render_filter(striptags(text), "safe")