Explorar el Código

Unshortify links when stripping html

Zed hace 7 años
padre
commit
2a2255d75a
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      src/formatters.nim

+ 5 - 1
src/formatters.nim

@@ -17,7 +17,11 @@ proc stripText*(text: string): string =
   text.replace(nbsp, " ").strip()
 
 proc stripHtml*(text: string): string =
-  let html = parseHtml(text)
+  var html = parseHtml(text)
+  for el in html.findAll("a"):
+    let link = el.attr("href")
+    if "http" in link:
+      el[0].text = link
   html.innerText()
 
 proc shortLink*(text: string; length=28): string =