summary refs log tree commit diff
path: root/gemtext.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-01-14 09:07:07 -0500
committerZach DeCook <zachdecook@librem.one>2023-01-14 09:07:07 -0500
commit74c1b89b728d7d1013b714adf39737cd27e045f3 (patch)
treea86a3a6828831155b13de03b2c761510aee383ab /gemtext.py
parentd236dd91d458035a455a4fa4f198aa1fb0e7fad9 (diff)
downloadbrowset-74c1b89b728d7d1013b714adf39737cd27e045f3.tar.gz
mime: Support plaintext format as well
Diffstat (limited to 'gemtext.py')
-rw-r--r--gemtext.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/gemtext.py b/gemtext.py
deleted file mode 100644
index 602d308..0000000
--- a/gemtext.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from textual.widgets import Button, Static
-from textual.app import ComposeResult
-from textual.containers import Container
-
-class Gemtext(Static):
-    """Gemtext widget."""
-    inPre = False
-
-    def __init__(self, fp, id):
-        super().__init__(id=id)
-        self.addlines(fp)
-
-    def addlines(self, fp):
-        for lin in fp:
-            line = lin
-            if type(line) is bytes:
-                line = line.decode("UTF-8")
-            line = line.rstrip("\r\n")
-            if line.startswith("```"):
-                self.inPre = not self.inPre
-                if self.inPre:
-                    self.inPre = Preformatted()
-                    self.mount(self.inPre)
-            elif self.inPre:
-                self.inPre.mount(Static(line, markup=False))
-            elif line.startswith("=>"):
-                path = line[2:].lstrip().split(' ')[0]
-                text = ' '.join(line[2:].lstrip().split(' ')[1:])
-                self.mount(Button(text or path, name=path))
-            elif 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))
-
-class Preformatted(Container):
-    pass
-
-if __name__ == "__main__":
-    from textual.app import App
-    class Test(App):
-        def compose(self) -> ComposeResult:
-            yield Gemtext(txt="#title\n=> /href link text\nworld star hiphop", id="yo")
-    app = Test()
-    app.run()