def link_title_uid_txt(i): if 'alternate' in i: link = i['alternate'][0]['href'] else: link = '' if 'title' in i: title = i['title'] title = unescape(title) else: title = '无题' rss_uid = i.get('id') or 1 snippet = i.get('summary') or i.get('content') or None if not snippet: return if snippet: htm = snippet['content'] if not htm: return htm = txttidy(htm) htm = txt_map('<pre', '</pre>', htm, pre_br) htm = tidy_fragment(htm, {'indent': 0})[0] htm = htm.replace('<br />', '\n') txt = htm2txt(htm) if not txt: return return link, title, rss_uid, txt
def txt_withlink(s): if type(s) is unicode: s = str(s) s = '\r'.join(map(str.rstrip, s.replace('\r\n', '\r').replace('\n', '\r').split('\r'))) s = escape(s) replace_code = ReplaceCode() s = txt_map('\r{{{', '\r}}}\r', '\r%s\r'%s, replace_code).strip() s = RE_BOLD.sub(replace_bold, s) s = replace_link_img(s) s = RE_AT.sub(replace_at, s) s = replace_code.loads(s) return s
def txt_withlink(s): if type(s) is unicode: s = str(s) s = '\r'.join( map(str.rstrip, s.replace('\r\n', '\r').replace('\n', '\r').split('\r'))) s = escape(s) replace_code = ReplaceCode() s = txt_map('\r{{{', '\r}}}\r', '\r%s\r' % s, replace_code).strip() s = RE_BOLD.sub(replace_bold, s) s = replace_link_img(s) s = RE_AT.sub(replace_at, s) s = replace_code.loads(s) return s
def txt_img_fetch(txt): return txt_map(r'图:', '\n', txt+'\n', fetch_pic).rstrip('\n')