This project demonstrates how to use the MDQ (Markdown Query) tool in a web browser by compiling it to WebAssembly.
The demo compiles the Rust-based MDQ library to WebAssembly, making it available to use directly in the browser. The web interface allows you to:
- Enter or paste Markdown content
- Specify a selector to query specific elements in the Markdown
- Choose the output format (Markdown or JSON)
- View the results instantly
See the SETUP_GUIDE.md
file for detailed setup instructions. In short:
# Install wasm-pack if you don't have it
cargo install wasm-pack
# Build the WebAssembly module
wasm-pack build --target web
# Serve the web demo (using any local web server)
npx http-server
Then open your browser and navigate to http://localhost:8080
MDQ uses a simple query language to select elements from Markdown documents. Here are some examples:
Syntax | Selects | String matcher matches... |
---|---|---|
# matcher |
section | section's header title |
- matcher |
unordered list items | text in the list item |
- [?] matcher |
unordered task items | task text |
[matcher](matcher) |
links | first matches link text, second matches URL |
For more details, see the Full User Manual.
src/lib.rs
- Rust code that exposes MDQ functionality to JavaScriptindex.html
- The web interfaceindex.js
- JavaScript code that interacts with the WebAssembly modulepkg/
- (Generated) Contains the compiled WebAssembly module and JavaScript bindingsSETUP_GUIDE.md
- Detailed instructions for setting up the projectTROUBLESHOOTING.md
- Solutions for common issuesbuild.ps1
- PowerShell script to automate the build process
If you encounter any issues during the build process, please refer to the TROUBLESHOOTING.md
file for common problems and their solutions.
MDQ is a command-line tool that lets you select specific elements from a Markdown document using a simple query language. You can install the original MDQ tool using one of these methods:
# Using cargo with git repository
cargo install --git https://github.com/yshavit/mdq
# Using Homebrew
brew install mdq
# Using Docker
docker pull yshavit/mdq
echo 'My [example](https://github.com/yshavit/mdq) markdown' | docker run --rm -i yshavit/mdq '[]()'
You can also download binaries from the latest release.
Special thank you to @jerrylususu for kickstarting this playground project!