Broken project to implement a cross-protocol browser in textual
gemtext: Format headers differently
Zach DeCook 2022-12-24
parent b9d3929 · commit 3bc4d14
-rw-r--r--browset.css13
-rw-r--r--browset.py2
-rw-r--r--gemtext.py4
3 files changed, 18 insertions, 1 deletions
diff --git a/browset.css b/browset.css
index a9af080..d965878 100644
--- a/browset.css
+++ b/browset.css
@@ -6,3 +6,16 @@
height: 3;
dock: top;
}
+.header {
+ content-align: center middle;
+}
+.h1.header {
+ border:double white;
+ text-style: bold;
+}
+.h2.header {
+ border-bottom: solid white;
+ text-style: bold;
+}
+.h3.header {
+}
diff --git a/browset.py b/browset.py
index 3b32939..2ab959b 100644
--- a/browset.py
+++ b/browset.py
@@ -13,7 +13,7 @@ class Browset(App):
Binding("ctrl+c,ctrl+q", "app.quit", "Quit", show=True),
]
- content = ["## Hello","* Bullet points","*OH Yeah!","=>URI some link"]
+ content = ["#h1", "## hey [b]Is this unformatted?[/b]", "yeah","#h1", "### h3"]
def compose(self) -> ComposeResult:
yield Footer()
yield Container(
diff --git a/gemtext.py b/gemtext.py
index 749e6dc..6c7dfca 100644
--- a/gemtext.py
+++ b/gemtext.py
@@ -18,6 +18,10 @@ class Gemtext(Static):
path = line[2:].lstrip().split(' ')[0]
text = ' '.join(line[2:].lstrip().split(' ')[1:])
self.mount(Button(text or path, name=path))
+ if line.startswith("#"):
+ count = line.split(' ')[0][0:3].count("#")
+ w = Static(line.lstrip("#"), markup=False, classes="header h"+str(count))
+ self.mount(w)
else:
self.mount(Static(line, markup=False))