added decktext parser and spec

This commit is contained in:
Luxferre
2025-12-29 22:30:42 +02:00
parent f12d149287
commit f4dece67e1
3 changed files with 272 additions and 0 deletions
+15
View File
@@ -188,6 +188,21 @@ Exports the following functions:
- `totp(key, time_step, digits=6)`: generate a `digits`-long TOTP code from (bytes-only) key, using `time_step` as the basis (30 seconds is default and the most common)
- `get_epoch()`: a helper platform-agnostic function to get the current Unix timestamp in seconds
### `deck.text`
A library that implements a [DeckText](decktext-spec.md) format parser. Exports a single class, `DeckText`, with the following methods:
- `doc = DeckText(src=None)` constructor: initialize a DeckText document object from the passed source
- `doc.load(src)`: load DeckText source into the existing document object.
After the source is loaded, the document object exposes two properties: `title` and `pages`.
The `title` property is a normal string that represents the document's title (read from the `<title>` HTML tag).
The `pages` property contains a list of DeckText pages in the form of `{content, links}` dictionary, where `content` is the rendered (ready-to-display) page content and `links` is the list of links present on the page.
Each link is in the form of `(url, label)` tuple. The client using this class for DeckText page rendering is supposed to provide a UI to visit the links based on this list.
### `deck.llm`
A helper library for interaction with remote LLM (large language model) endpoints that expose OpenAI-compatible API. As of now, it only exports a single class, `LLMChat`, to encapsulate all the interaction.