isosphere / KoHighlights

KOHighlights is a utility for viewing KOReader's highlights and/or export them to simple text, html, csv or markdown files.
MIT License
1 stars 0 forks source link

Support User-Modifiable Template Export #1

Open isosphere opened 1 year ago

isosphere commented 1 year ago

I want to be able to export annotations in a format that matches a specific structure of plain text output[^1]. If we support user-modifiable templates, users can fine-tune the exports from KoHighlight to match any plain text format they might want: plain text, CSV, markdown, HTML, JSON, TOML, etc.

[^1]: specifically, I want to generate markdown files that use properties as supported by logseq using book metadata

To that end, I propose that we identify an appropriate templating dependency and integrate it as an export choice in KoReader.

The user would not have control over what context variables are sent to the template; we'd just firehose them the metadata in a consistent variable format:

isosphere commented 1 year ago

Templating Dependency Selection

Considerations

Candidates

Selection

IMO the top candidates are Jinja and Mako. Jinja's syntax is more similar to Django's, and it does not allow embedded Python code which allows us to worry a bit less about malicious templates - even if they would only ever be user generated.

I think Jinja is a good choice.