Bert Livens: 2
Added support for <dd> and <dt> tags to ansicat.
Added support for <dd> and <dt> tags to ansicat to render websites like https://fsl.software/ better.
4 files changed, 6 insertions(+), 4 deletions(-)
Signed-off-by: Bert Livens <bert@bertlivens.be>
---
This shows description elements indented like a blockquote and starts a new
paragraph for a description title. The website I used as an example is
https://fsl.software/ .
Hi Bert,
Could you please fix the small conflict in the changelog (I’ve pushed a
commit today). Also, don’t hesitate to add your name.
CHANGELOG | 1 +ansicat.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d8fe936..95ed63d 100644
--- a/CHANGELOG+++ b/CHANGELOG
@@ -10,6 +10,7 @@
- offpunk: add list autocompletion to "tour"
- offpunk: removed "blackbox", which has not been used nor maintained
- offpunk: "gus" was broken, it is functionnal again
+- ansicat: added support for HTML description elements <dt> and <dd>## 2.1 - December 15th 2023
- freshly updated gemtext/rss links are highlighted ("new_link" theme option)
diff --git a/ansicat.py b/ansicat.py
index 8b92527..e4ef7ed 100755
--- a/ansicat.py+++ b/ansicat.py
@@ -1085,7 +1085,7 @@ class HtmlRenderer(AbstractRenderer):
toreturn = " " + toreturn
return toreturn
def recursive_render(element,indent="",preformatted=False):
- if element.name == "blockquote":+ if element.name in ["blockquote", "dd"]: r.newparagraph()
r.startindent(" ",reverse=" ")
for child in element.children:
@@ -1093,7 +1093,7 @@ class HtmlRenderer(AbstractRenderer):
recursive_render(child,indent="\t")
r.close_theme("blockquote")
r.endindent()
- elif element.name in ["div","p"]:+ elif element.name in ["div","p","dt"]: r.newparagraph()
for child in element.children:
recursive_render(child,indent=indent)
--
2.43.0
[PATCH v2] Added support for <dd> and <dt> tags to ansicat to render websites like https://fsl.software/ better.
Export this patch
Signed-off-by: Bert Livens <bert@bertlivens.be>
---
Fixed the merge conflict.
CHANGELOG | 1 +ansicat.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 07d31c3..bc4fb07 100644
--- a/CHANGELOG+++ b/CHANGELOG
@@ -11,6 +11,7 @@
- offpunk: removed "blackbox", which has not been used nor maintained
- offpunk: "gus" was broken, it is functionnal again
- opnk/offpunk: more informative prompt in less
+- ansicat: added support for HTML description elements <dt> and <dd> (by Bert Livens)## 2.1 - December 15th 2023
- freshly updated gemtext/rss links are highlighted ("new_link" theme option)
diff --git a/ansicat.py b/ansicat.py
index 8b92527..e4ef7ed 100755
--- a/ansicat.py+++ b/ansicat.py
@@ -1085,7 +1085,7 @@ class HtmlRenderer(AbstractRenderer):
toreturn = " " + toreturn
return toreturn
def recursive_render(element,indent="",preformatted=False):
- if element.name == "blockquote":+ if element.name in ["blockquote", "dd"]: r.newparagraph()
r.startindent(" ",reverse=" ")
for child in element.children:
@@ -1093,7 +1093,7 @@ class HtmlRenderer(AbstractRenderer):
recursive_render(child,indent="\t")
r.close_theme("blockquote")
r.endindent()
- elif element.name in ["div","p"]:+ elif element.name in ["div","p","dt"]: r.newparagraph()
for child in element.children:
recursive_render(child,indent=indent)
--
2.43.0