TUIのMarkdownブラウザのTextual Markdown Browser を少し試す

TextualというTUIのPythonライブラリを利用したMarkdownブラウザのTextual Markdown Browser というものを見かけたので試してみました.

導入
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install textual-markdown
実行
$ python3 -m textual_markdown ./README.md

textual markdown browser

マウスホイールでのスクロールにも対応していて動作がするするといい感じです.TOCからのページ内リンクもマウスクリックで動作します.といい感じなのですが,以下のようにMarkdownによりエラーになって動作しないものが多いです.

$ python3 -m textual_markdown ~/src/reveal.js/README.md
╭──────────────────────── Traceback (most recent call last) ─────────────────────────╮
│ /home/matoken/.local/lib/python3.10/site-packages/textual_markdown/widgets.py:601  │
│ in on_tocupdated                                                                   │
│                                                                                    │
│   598 │   │   yield MarkdownDocument()                                             │
│   599 │                                                                            │
│   600 │   def on_tocupdated(self, message: TOCUpdated) -> None:                    │
│ ❱ 601 │   │   self.query_one(MarkdownTOC).toc = message.toc                        │
│   602 │   │   message.stop()                                                       │
│   603 │                                                                            │
│   604 │   def on_tocselected(self, message: TOCSelected) -> None:                  │
│                                                                                    │
│ ╭───────────────────── locals ─────────────────────╮                               │
│ │ message = TOCUpdated(MarkdownDocument())         │                               │
│ │    self = MarkdownBrowser(classes={'-show-toc'}) │                               │
│ ╰──────────────────────────────────────────────────╯                               │
│                                                                                    │
│ /home/matoken/.local/lib/python3.10/site-packages/textual_markdown/widgets.py:525  │
│ in watch_toc                                                                       │
│                                                                                    │
    :

現段階では表示でないMarkdownが多いのでhtmlに変換してブラウザで見るほうが良さそうです.

$ pandoc -f markdown -t html ~/src/reveal.js/README.md | w3m -T text/html
$ pandoc -f markdown -t html ~/src/reveal.js/README.md | lynx -stdin
環境
$ pip3 show textual-markdown
Name: textual-markdown
Version: 0.1.1
Summary: Markdown viewer widgets for Textual
Home-page:
Author: Will McGugan
Author-email: willmcgugan@gmail.com
License: MIT
Location: /home/matoken/.local/lib/python3.10/site-packages
Requires: markdown-it-py, textual
Required-by:
$ dpkg-query -W python3 python3-pip pandoc lynx w3m
lynx    2.9.0dev.11-1
pandoc  2.17.1.1-1.1
python3 3.10.6-3+b1
python3-pip     22.3.1+dfsg-1
w3m     0.5.3+git20220429-1+b1
$ lsb_release --all
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)