https://github.com/asg017/sqlite-md
A SQLite extension for parsing, querying, and generating HTML from Markdown documents.
https://github.com/asg017/sqlite-md
sqlite sqlite-extension
Last synced: 8 months ago
JSON representation
A SQLite extension for parsing, querying, and generating HTML from Markdown documents.
- Host: GitHub
- URL: https://github.com/asg017/sqlite-md
- Owner: asg017
- Created: 2023-02-27T19:25:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-27T19:25:34.000Z (almost 3 years ago)
- Last Synced: 2025-04-01T06:15:51.285Z (9 months ago)
- Topics: sqlite, sqlite-extension
- Language: Rust
- Homepage:
- Size: 5.86 KB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `sqlite-md`
A SQLite extension for parsing, querying, and generating HTML from Markdown documents. Based on [markdown-rs](https://github.com/wooorm/markdown-rs) and [sqlite-loadable-rs](https://github.com/asg017/sqlite-loadable-rs).
Work in progress, not meant to be widely shared!
**Generate HTML from markdown**
```sql
select md_to_html('
# The largest heading
Paragraph with **some bold**, _underlines_, [links](https://google.com) and !
');
/*
'
The largest heading
Paragraph with some bold, underlines, links and
!
'
*/
```
**Extract all links from a markdown document**
```sql
select
details ->> 'url' as url
from md_ast(readfile('README.md'))
where node_type = 'Link';
/*
┌──────────────────────────────────────────────┐
│ url │
├──────────────────────────────────────────────┤
│ https://github.com/wooorm/markdown-rs │
│ https://github.com/asg017/sqlite-loadable-rs │
└──────────────────────────────────────────────┘
*/
```
** Get all code samples from markdown**
```sql
select
value as code,
details ->> 'language' as language
from md_ast(readfile('README.md'))
where node_type = 'Code';
/*
┌──────────────────────────────────────────────────────────────┬──────────┐
│ code │ language │
├──────────────────────────────────────────────────────────────┼──────────┤
│ select md_to_html(' │ sql │
│ # The largest heading │ │
│ │ │
│ Paragraph with **some bold**, _underlines_, [links](https:// │ │
│ google.com) and ! │ │
│ │ │
│ '); │ │
│ /* │ │
│ '
The largest heading
│ │
│ Paragraph with some bold, underlines │ │
│ , links and
!
' │ │
│ *\/ │ │
├──────────────────────────────────────────────────────────────┼──────────┤
│ select │ sql │
│ details ->> 'url' as url │ │
│ from md_ast(readfile('README.md')) │ │
│ where node_type = 'Link'; │ │
│ /* │ │
│ ┌──────────────────────────────────────────────┐ │ │
│ │ url │ │ │
│ ├──────────────────────────────────────────────┤ │ │
│ │ https://github.com/wooorm/markdown-rs │ │ │
│ │ https://github.com/asg017/sqlite-loadable-rs │ │ │
│ └──────────────────────────────────────────────┘ │ │
│ *\/ │ │
├──────────────────────────────────────────────────────────────┼──────────┤
│ select │ sql │
│ value as code, │ │
│ details ->> 'language' as language │ │
│ from md_ast(readfile('README.md')) │ │
│ where node_type = 'Code'; │ │
└──────────────────────────────────────────────────────────────┴──────────┘
*/
```