Rust Markdown

Open-source Rust projects categorized as Markdown

Top 23 Rust Markdown Projects

  • gutenberg

    A fast static site generator in a single binary with everything built-in. https://www.getzola.org

    Project mention: Tufte CSS | news.ycombinator.com | 2023-03-05
  • dprint

    Pluggable and configurable code formatting platform written in Rust.

    Project mention: What would you rewrite in Rust? | reddit.com/r/rust | 2023-02-11
  • InfluxDB

    Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.

  • mdcat

    cat for markdown

    Project mention: what is the simplest MarkDown viewer ? | reddit.com/r/linux | 2023-01-03

    Quickest way I found to view .md files from my terminal is mdcat.

  • comrak

    CommonMark + GFM compatible Markdown parser and renderer

    Project mention: Create a Markdown Editor with Rust and React | dev.to | 2022-10-13

    I opened up the src/App.tsx and added a and synced any text changes to React state.

    import { useState } from "react";
    import reactLogo from "./assets/react.svg";
    import { invoke } from "@tauri-apps/api/tauri";
    import "./App.css";
    
    function App() {
      const [markdown, setMarkdown] = useState("");
    
      return (
        
    className="container">

    Welcome to Tauri!

    Click on the Tauri, Vite, and React logos to learn more.

    className="row">
    id="greet-input" onChange={(e) => setMarkdown(e.currentTarget.value)} />
    ); } export default App;
    Enter fullscreen mode Exit fullscreen mode

    Now that we have a textbox we can write Markdown inside, let’s convert that to HTML to preview.

    Creating a Tauri command

    We’ll need to use Tauri commands to communicate between the frontend and backend - and vice versa (similar to the IPC layer in Electron).

    Tauri comes with an example Tauri command called greet() already setup, so let’s use that and change it to parse Markdown. Open up src-tauri/src/main.rs and change it to the following:

    #![cfg_attr(
        all(not(debug_assertions), target_os = "windows"),
        windows_subsystem = "windows"
    )]
    // Import comrak
    use comrak::{markdown_to_html, ComrakOptions};
    
    // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
    #[tauri::command]
    fn greet(markdown: &str) -> String {
        // format!("Hello, {}! You've been greeted from Rust!", name)
    
            // Parse the markdown text to HTML
        let html = markdown_to_html(&markdown, &ComrakOptions::default());
    
        println!("Markdown parsed into HTML \n");
        println!("{html}");
    
            // We return the HTML to the frontend (in Rust, we return by omitting the `;`)
        html
    }
    
    fn main() {
        tauri::Builder::default()
                    // Here is where we add our Tauri commands to our app
            .invoke_handler(tauri::generate_handler![greet])
            .run(tauri::generate_context!())
            .expect("error while running tauri application");
    }
    
    Enter fullscreen mode Exit fullscreen mode

    And in our frontend, let’s create a we can press to run the Tauri command. We use the invoke function provided by Tauri that’ll call a Tauri command with the same name.

    import { useState } from "react";
    import reactLogo from "./assets/react.svg";
    import { invoke } from "@tauri-apps/api/tauri";
    import "./App.css";
    
    function App() {
      const [html, setHtml] = useState("");
      const [markdown, setMarkdown] = useState("");
    
      async function greet() {
        // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
        setHtml(await invoke("greet", { markdown }));
      }
    
      return (
        <div className="container">
          <h1>Welcome to Tauri!h1>
    
          <div className="row">
            <a href="https://vitejs.dev" target="_blank">
              <img src="/vite.svg" className="logo vite" alt="Vite logo" />
            a>
            <a href="https://tauri.app" target="_blank">
              <img src="/tauri.svg" className="logo tauri" alt="Tauri logo" />
            a>
            <a href="https://reactjs.org" target="_blank">
              <img src={reactLogo} className="logo react" alt="React logo" />
            a>
          div>
    
          <p>Click on the Tauri, Vite, and React logos to learn more.p>
    
          <div className="row">
            <div>
              <textarea
                id="greet-input"
                onChange={(e) => setMarkdown(e.currentTarget.value)}
              />
              <button type="button" onClick={() => greet()}>
                Convert to HTML
              button>
            div>
          div>
          <p>{html}p>
        div>
      );
    }
    
    export default App;
    
    Enter fullscreen mode Exit fullscreen mode

    If you type some Markdown into the text box and click the button, it should print out raw HTML representing your Markdown. Here’s the commit on Github for reference.

    But how do we preview the HTML?

    If we wanted to preview the HTML, we could use React’s dangerouslySetInnerHTML to inject the HTML inside our app:

    const createMarkdownMarkup = () => ({
      __html: html
    })
    
    <div dangerouslySetInnerHTML={createMarkdownMarkup()} />
    
    Enter fullscreen mode Exit fullscreen mode

    And ideally, this isn’t as “dangerous” as it sounds, because Comrak sanitizes the Markdown output for any malicious code before converting to HTML 👍

    We could also update the onChange function to run our conversion process, instead of waiting for a button press, so we “instantly” see a live preview. In my case, I do it in a useEffect with a refresh boolean — but it’s all good. Note, this is a little risky, since the user might be able to break the app, so in production it’d be best to create a cache of the last “working” preview just in case one fails.

    import { useEffect, useRef, useState } from "react";
    import reactLogo from "./assets/react.svg";
    import { invoke } from "@tauri-apps/api/tauri";
    import "./App.css";
    
    function App() {
      const [html, setHtml] = useState("");
      const [markdown, setMarkdown] = useState("");
      const [refreshCheck, setRefreshCheck] = useState(false);
    
      async function greet() {
        setRefreshCheck(true);
      }
    
      useEffect(() => {
        const parseMarkdown = async () => {
          setHtml(await invoke("greet", { markdown }));
          setRefreshCheck(false);
          console.log("new markdown");
        };
        console.log("refreshed");
        if (refreshCheck) {
          parseMarkdown();
          console.log("parsing!");
        }
      }, [refreshCheck]);
    
      const createMarkdownMarkup = () => ({
        __html: html,
      });
    
      const handleTextArea = (e) => {
        setMarkdown(e.currentTarget.value);
        setRefreshCheck(true);
        console.log("need new markdown!");
      };
    
      return (
        <div>
          <div className="row">
            <div>
              <textarea id="greet-input" onChange={handleTextArea} />
              <button type="button" onClick={() => greet()}>
                Convert to HTML
              button>
            div>
          div>
          <div dangerouslySetInnerHTML={createMarkdownMarkup()} />
        div>
      );
    }
    
    export default App;
    
    Enter fullscreen mode Exit fullscreen mode

    Here’s the commit on Github for reference.

    The world is your Markdown

    Now you can parse Markdown using Rust, there’s lots of cool stuff you can do! From CLIs to UI apps, you can make tools that help people use Markdown. And ideally, this will run faster than most other implementations (like Electron apps) because it’s running in Rust (unless you can write Markdown tooling in C or something).

    I hope this helped you understand some Rust fundamentals and new techniques to use down the line.

    As always, if you have any questions or make something using this guide, tag me on Twitter. I’d love to help or see what cool stuff you’re hacking on.

    You can find the complete code for this post in my tauri-markdown-editor repo.

    Stay regular!
    Ryo

  • termimad

    A library to display rich (Markdown) snippets and texts in a rust terminal application

  • vim-markdown-composer

    An asynchronous markdown preview plugin for Vim and Neovim.

    Project mention: Markdown in neovim | reddit.com/r/neovim | 2023-02-27

    Currently using https://github.com/euclio/vim-markdown-composer and am happy with it.

  • crowbook

    Converts books written in Markdown to HTML, LaTeX/PDF and EPUB

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

  • markdown-rs

    CommonMark compliant markdown parser in Rust with ASTs and extensions

    Project mention: Looking for an extensible markup language (aka Markdown, Asciidoc, ...) implemented in Rust. | reddit.com/r/rust | 2023-01-13

    Have you considered markdown-rs?

  • obsidian-extract-url

    Plugin to extract markdown out of urls

    Project mention: Obsidian Roundup: Demo Vaults, PKM History, &amp; an editable graph view | reddit.com/r/ObsidianMD | 2022-05-28
  • rust-book-fr

    :fr: French translation of the book "The Rust Programming Language"

    Project mention: Contribute to the diagnostic translation effort! | Inside Rust Blog | reddit.com/r/rust | 2022-08-17

    We already have them translated here ! My favorite is "Rustacean" being translated to "Rustacé".

  • cbfmt

    A tool to format codeblocks inside markdown and org documents.

    Project mention: null-ls-embedded - Format embedded code using null-ls | reddit.com/r/neovim | 2022-12-02

    https://github.com/lukas-reineke/cbfmt also exists as a standalone tool for this

  • tp-note

    Minimalistic note taking: save and edit your clipboard content as a note file (Gitlab mirror)

    Project mention: Tp-Note: Minimalistic note taking | news.ycombinator.com | 2023-02-04
  • marko-editor

    Marko Editor is a simple WYSIWYG editor for note taking.

  • fastn

    🚧 (Alpha stage software) FTD: Programming Language For Prose 🚧

    Project mention: Is any Indian company doing something unique. Apart from building just basic CRUD apps? | reddit.com/r/bangalore | 2023-01-30

    We have added function support in FTD as well. Not yet properly documented. Checkout this example: https://github.com/ftd-lang/ftd/blob/main/t/html/6-function.ftd

  • gisture

    A minimal and flexible blog generator based on GitHub Gist.

  • parsedown

    WASM code for parsing Markdown into HTML with light output tweaking (by rodneylab)

    Project mention: Deno Fresh WASM: Code Modules in Rust | dev.to | 2023-02-01

    The complete is in Rodney Lab GitHub repo. As a next step you might consider publishing your WASM module to deno.land/x so other developers can easily use it. This is something I did with the parsedown module. It has code I use for the Newsletter and parses Markdown to HTML as well as generate email HTML and plaintext emails. Let me know if you would like to see a short video on publishing a Deno module.

  • mini_markdown

    Dependency free markdown

  • criterion-table

    Generate markdown comparison tables from `cargo-criterion` JSON output

  • tax

    CLI Task List Manager

    Project mention: One Thing – Put a single task or goal in your menu bar | news.ycombinator.com | 2022-12-30

    I made for myself something similar, for display in my shell prompt https://github.com/netgusto/tax

  • pup

    A command-line tool that automatically uploads images from the markdown document to the GitHub repo and replaces the paths with the returned URL. (by SteveLauC)

    Project mention: I wrote a markdown pic uploader named pup | reddit.com/r/rust | 2022-04-19

    The repo is [here](https://github.com/SteveLauC/pup), welcome to have some fun:)

  • orion

    A static site generator written in Rust to create a simple blog from Markdown files (by adriantombu)

    Project mention: What’s everyone working on this week (1/2023)? | reddit.com/r/rust | 2023-01-02

    I also have a few ideas to improve my current very basic static site generator https://github.com/adriantombu/orion

  • germ

    🦠 The Ultimate Gemini Toolkit.

    Project mention: GemRest News | reddit.com/r/geminiprotocol | 2022-05-18

    Germ is released: A minimal dependency, Gemini-oriented library for all your Gemini needs: AST construction, format conversions (Gemtext to Markdown, HTML, etc.), request creation, and meta utilities.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020). The latest post mention was on 2023-03-05.

Rust Markdown related posts

Index

What are some of the best open-source Markdown projects in Rust? This list will help you:

Project Stars
1 gutenberg 10,587
2 dprint 1,766
3 mdcat 1,582
4 comrak 843
5 termimad 671
6 vim-markdown-composer 601
7 crowbook 592
8 markdown-rs 294
9 obsidian-extract-url 156
10 rust-book-fr 136
11 cbfmt 121
12 tp-note 84
13 marko-editor 49
14 fastn 49
15 gisture 27
16 parsedown 16
17 mini_markdown 15
18 criterion-table 15
19 tax 13
20 pup 12
21 orion 9
22 md-footer 8
23 germ 7
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com