An open API service indexing awesome lists of open source software.

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.

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 ![images](https://placeholder.com/assets/images/150x150-500x500.png)!

');
/*
'

The largest heading


Paragraph with some bold, underlines, links and images!

'
*/
```

**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 ![images](https://placeholder.com/assets/ima │ │
│ ges/150x150-500x500.png)! │ │
│ │ │
│ '); │ │
│ /* │ │
│ '

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'; │ │
└──────────────────────────────────────────────────────────────┴──────────┘
*/
```