Giter VIP home page Giter VIP logo

markdown-queries's Introduction

markdown-queries README

This is the repository for the markdown-queries extension which adds dynamic query support for markdown previews. This extension is heavily influenced by Obsidian Dataview

Demo of markdown sql query in preview

Features

This is more POC at this point, but it is possible to put a sql query against a specific sqlite database created by MarkdownDB

There is a test workspace that you can open with the extension in debug mode after running

npm run prep-test-workspace

If you open the workspace in src/test/test-workspace and open dynamic.md you should see the results of a query against the markdown files in the repo.

The upshot is that you can do sql queries against against your markdown files including frontmatter attributes, tags, todos, etc.

How it works

The extension declares that it extends the markdown-it processor in the standard markdown extension.

It provides a highlighter plugin to the markdown parser that calls a service object to run queries on the sql.js database that is loaded into memory on initialization from the markdown.db file in the workspace.

This is different from a preview script which runs in a webview without access to the rest of the vscode API.

Future

This extension has a lot of potential but there is plenty of work to do to make this useful to anyone.

High level items that need dealing with:

  • Indexing - this currently relies on the DB being there already. It will take some work to figure out how to get MarkdownDB to run inside of vscode and use sql.js and sync the DB to disk. (I looked into using sqlite but native modules in vscode have a lot of issues Native node modules from extensions)

  • Query language - Using SQL directly will be pretty awkward for most cases. At the same time, I don't want to write a custom query system. My current thought is to do some transparent macros to deal with common joins or accessing json metadata.

  • Formatting - It would be nice to have some options for more flexible formatting of results for things like group_by and of course making todos and such look nice. This might require figuring out the split between the markdown-it plugin and preview scripts.

  • Integration with Foam - This extension comes out of my desire to get more out of my knowledgebase, but at the moment it doesn't seem necessary to tie the two together yet.

  • Security - Running arbitrary sql from user input? https://xkcd.com/327/

markdown-queries's People

Contributors

dstengle avatar

Stargazers

Borja avatar  avatar

Watchers

 avatar  avatar

Forkers

jstockdi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.