~lioploum/offpunk-devel

Added support for <dd> and <dt> tags to ansicat. v1 PROPOSED

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(-)
Thanks, merged!
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~lioploum/offpunk-devel/patches/48993/mbox | git am -3
Learn more about email & git

[PATCH] Added support for <dd> and <dt> tags to ansicat. Export this patch

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/ .
 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
Thanks, merged!