Markdown renderer for Dear ImGui using MD4C parser

Overview

imgui_md

Markdown renderer for Dear ImGui using MD4C parser.

C++11 or above

imgui_md currently supports the following markdown functionality:

  • Wrapped text
  • Headers
  • Emphasis
  • Ordered and unordered list, sub-lists
  • Link
  • Image
  • Horizontal rule
  • Table
  • Underline
  • Strikethrough
  • HTML elements: <br> <hr> <u> <div> &nbsp;
  • Backslash Escapes

Most format tags can be mixed!

Current tables limitations:

  • Width of the columns are defined by header
  • Cells are always left aligned

Usage

Add imgui_md.h imgui_md.cpp md4c.h md4c.c to your project and use the following code:

#include "imgui_md.h"

//Fonts and images (ImTextureID) must be loaded in other place,
//see https://github.com/ocornut/imgui/blob/master/docs/FONTS.md
extern ImFont* g_font_regular;
extern ImFont* g_font_bold;
extern ImFont* g_font_bold_large;
extern ImTextureID g_texture1

struct my_markdown : public imgui_md 
{
	
	
	ImFont* get_font() const override
	{
		if (m_is_table_header) {
			return g_font_bold;
		}

		switch (m_hlevel)
		{
		case 0:
			return m_is_strong ? g_font_bold : g_font_regular;
		case 1:
			return g_font_bold_large;
		default:
			return g_font_bold;
		}
	};

	
	void open_url() const override
	{
		//platform dependent code
		SDL_OpenURL(m_href.c_str());
	}


	bool get_image(image_info& nfo) const override
	{
		//use m_href to identify images
		nfo.texture_id = g_texture1;
		nfo.size = {40,20};
		nfo.uv0 = { 0,0 };
		nfo.uv1 = {1,1};
		nfo.col_tint = { 1,1,1,1 };
		nfo.col_border = { 0,0,0,0 };
		return true;
	}
	
	void html_div(const std::string& dclass, bool e) override
	{
		if (dclass == "red") {
			if (e) {
				m_table_border = false;
				ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255));
			} else {
				ImGui::PopStyleColor();
				m_table_border = true;
			}
		}
	}
};


//call this function to render your markdown
void markdown(const char* str, const char* str_end)
{
	static my_markdown s_printer;
	s_printer.print(str, str_end);
}

Examples

# Table

Name &nbsp; &nbsp; &nbsp; &nbsp; | Multiline &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>header  | [Link&nbsp;](#link1)
:------|:-------------------|:--
Value-One | Long <br>explanation <br>with \<br\>\'s|1
~~Value-Two~~ | __text auto wrapped__\: long explanation here |25 37 43 56 78 90
**etc** | [~~Some **link**~~](https://github.com/mekhontsev/imgui_md)|3

# List

1. First ordered list item
2. Another item
   * Unordered sub-list 1.
   * Unordered sub-list 2.
1. Actual numbers don't matter, just that it's a number
   1. **Ordered** sub-list 1
   2. **Ordered** sub-list 2
4. And another item with minuses.
   - __sub-list with underline__
   - sub-list with escapes: \[looks like\]\(a link\)
5. ~~Item with pluses and strikethrough~~.
   + sub-list 1
   + sub-list 2
   + [Just a link](https://github.com/mekhontsev/imgui_md).
      * Item with [link1](#link1)
      * Item with bold [**link2**](#link1)

<div class = "red">

This table | is inside an | HTML div
--- | --- | ---
Still | ~~renders~~ | __nicely__
Border | **is not** | visible

</div>

Credits

imgui_markdown for ideas

Martin Mitáš for MD4C

Omar Cornut for Dear ImGui

Owner
Dmitry Mekhontsev
Dmitry Mekhontsev
ImGuiFileDialog is a file selection dialog built for (and using only) Dear ImGui

ImGuiFileDialog Purpose ImGuiFileDialog is a file selection dialog built for (and using only) Dear ImGui. My primary goal was to have a custom pane wi

Aiekick 669 Jun 25, 2022
Dear IMGUI + Render + Window handling, amalgamation in two files ready to use

imgui-app Imgui-app is an amalgamation of two amazing projects Dear Imgui and Sokol libraries into two files to make it very easy to start working wit

PpluX 100 Jun 15, 2022
A file dialog library for Dear ImGui

ImFileDialog A simple file dialog library for Dear ImGui. This library supports favorites, actual Windows icons, image previews, zooming in, etc... DI

dfranx 341 Jun 21, 2022
dear imgui + glfw framework

ImFrame ImFrame is a lightweight framework designed to provide you with a window and graphical backend for the Dear ImGui library. Unlike more traditi

null 43 Jun 7, 2022
A (very) simple notification wrapper for Dear ImGui

imgui-notify Is a header-only wrapper made to create notifications with Dear ImGui. As I couldn't find any library for this I just decided to create m

Patrick 159 Jun 16, 2022
Example program for integrating Dear ImGui and GLFW into Source's App System

This is an example program for integrating Dear ImGui and GLFW into Source's app system, the same thing Source's tools use. Feel free to do with this

null 9 Apr 16, 2022
X11 + GLFW + Dear ImGUI Overlay

Dear ImGUI Overlay X11 + GLFW + Dear ImGUI Overlay made by rdbo Based on https://github.com/rdbo/glfw-overlay How to use? In main.c, there is a window

Rdbo 4 Mar 30, 2022
Diagon transforms markdown-style expression into an ascii-art representation.

Diagon is an interactive interpreter. It transforms markdown-style expression into an ascii-art representation.It is written in C++ and use WebAssembly, HTML and CSS to make a Web Application.

Arthur Sonzogni 913 Jun 22, 2022
o/ ImGui Builder is a graphical framework for assembling imgui codes in your interface easily

IMGUI BUILDER The project consists a gui editor of the Imgui framework EDITOR Menu Export 1 - Export cpp file 2 - Cpp file Credits Credits for Shadowy

Code Building 343 Jun 28, 2022
A cross-platform wrapper for using SDL2 with ImGui

ImSDL2 ImSDL2 is an open source "wrapper" of imgui backends available for SDL2. It aims to provide a backend-independent yet simple interface for inte

terens 5 Feb 2, 2022
A ImGui Application with Multi Viewports and Docking using D3D11

ImGui-Application Informations A ImGui Application with Multi Viewports and Docking using D3D11 Build You need the DirectX SDK, here the Download link

Argon Projects 9 May 3, 2022
Generate Height map with Generator (OpenGL and imgui) and Construct Splat Map with generated height map using Algorithm

Generate Height map with Generator (OpenGL and imgui) and Construct Splat Map with generated height map using Algorithm(DPS, BFS, Gradient Descent ... etc) . At Renderer, with height map and blend map which are generated in front of this stage, render high quality terrain with OpenGL

Snowapril 35 Mar 22, 2022
Simpler ImGui Backend Implementation for VulkanHpp.

ImGui-VulkanHpp Simpler ImGui Backend Implementation for VulkanHpp.

takiyu 24 Mar 24, 2022
ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages.

ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages. By zig contained I mean that ZT is intend

null 80 Jun 18, 2022
ImTricks is a collection of useful functions for expanding / improving the functionality of the ImGui.

ImTricks ImTricks is a collection of useful functions for expanding / improving the functionality of the ImGui. At the moment it has in itself: Functi

Alexander Pers0na2 22 Jun 13, 2022
Expose the ImGui framework to clasp

Expose the ImGui framework to clasp Installing in the clasp source tree cd clasp/extensions git clone https://github.com/clasp-developers/imgui-clasp

clasp 4 Oct 11, 2021
Growtopia android modmenu with ImGui

Growtopia Android ImGUI Growtopia android modmenu with ImGUI. Features Built with ImGUI. Coming Soon None Requirements The following dependencies are

ZTz 50 Jun 17, 2022
Partial source of the ImGui interfaces used in the Rocket League version of CodeRed.

CodeRed-ImGui Raw source of the ImGui interfaces used in the Rocket League version of CodeRed. About This repo is just part of the ImGui source used i

CodeRed 7 Jun 18, 2022
Sample project to use ImGui + GLFW + OpenGL3

About just a sample project to use ImGui ( https://github.com/ocornut/imgui ) Note Windows 11 Visual Studio 2019 + cmake-gui WSL2 on Windows 11 apt in

iwatake 4 Dec 23, 2021