Remove html from tweet preview

This commit is contained in:
Zed 2019-10-10 11:35:48 +02:00
parent e7c5085365
commit fe15003665
2 changed files with 7 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import strutils, strformat, sequtils, htmlgen, xmltree, times, uri, tables
import strutils, strformat, sequtils, times, uri, tables
import xmltree, htmlparser, htmlgen
import regex
import types, utils, query
@ -92,3 +93,7 @@ proc getTwitterLink*(path: string; params: Table[string, string]): string =
result = $(parseUri("https://twitter.com") / path ? p)
if username.len > 0:
result = result.replace("/" & username, "")
proc getTweetPreview*(text: string): string =
let html = parseHtml(text)
html.innerText()

View file

@ -57,7 +57,7 @@ proc renderMain*(body: VNode; req: Request; title="Nitter"; titleText=""; desc="
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(property="og:type", content=`type`)
meta(property="og:title", content=titleText)
meta(property="og:description", content=desc)
meta(property="og:description", content=getTweetPreview(desc))
meta(property="og:site_name", content="Nitter")
for url in images: