Skip to content

extend markdown syntax support (tables and code)#43

Open
mgerhardy wants to merge 4 commits into
enkisoftware:mainfrom
mgerhardy:main
Open

extend markdown syntax support (tables and code)#43
mgerhardy wants to merge 4 commits into
enkisoftware:mainfrom
mgerhardy:main

Conversation

@mgerhardy

@mgerhardy mgerhardy commented Jan 22, 2026

Copy link
Copy Markdown

see #17

also added hand cursors to the link handling.

there are a few whitespace issues in the header file - some indentations are made with spaces and some with tabs. This sometimes makes it hard to follow the code paths.

Table rendering

... showing the markdown from https://github.com/vengi-voxel/vengi/blob/master/docs/Formats.md

Bildschirmfoto vom 2026-01-22 16-33-29

Code rendering

... showing the markdown from https://github.com/vengi-voxel/vengi/blob/master/docs/Palette.md

Bildschirmfoto vom 2026-01-22 16-34-34

@dougbinks

Copy link
Copy Markdown
Member

Once again thanks for this Martin!

Excellent stuff at first glance, the output looks really good.

I note that this doesn't use a config flag, I think we may need to add these for table and code support otherwise it may introduce formatting where there was none before and I want to keep backwards compatibility.

Note (as per previous PR): it may take a while to review PRs at the moment as I'm extremely busy for a few weeks. Additionally I think I need to create a simple example and test suite before extending imgui_markdown too much, as the intention is to be both lightweight and fast.

@petrihakkinen

petrihakkinen commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

This is great stuff! I gave this a spin and found a couple of issues.

  1. Code inside emphasis causes corrupt rendering
  2. Last column is not rendered when trailing pipe is omitted in tables. This issue is quite minor since it can be worked around easily.
  3. The parsing logic for tables is eager so any line starting with "|" (even in prose) begins a table. In GFM, a delimiter row ("| --- | --- |") is what defines a table but this adds complexity to the parser requiring either lookahead or buffering the column names...
  4. Markdown containing multiple tables have conflicting IDs (all tables have ID "##mdtable"). This does not seem to cause ill effects right now, but it probably means all instances use the same table data storage. This could cause issue in the future, e.g. if we allow resizing table columns. Perhaps current parsing position could be pushed to the ID stack before BeginTable?

Below is a markdown and its rendering showing issues 1 - 3.

### Code inside emphasis causes corrupt rendering

*use the `print` function*

### Last column is not rendered when trailing pipe is omitted

| Syntax      | Description
| ----------- | -----------
| Header      | Title
| Paragraph   | Text

(Leading and trailing pipes are optional in Github Flavored Markdown) 

### Incorrect detection of tables when delimiter row is absent

Absolute values:
|x| + |y| >= 0

Shell pipelines:
  | grep foo | sort | uniq

Bitwise OR results:
  | 0x0F | 0xF0 | 0xFF |

(the delimiter row "| --- | --- |" is what defines a table)

Rendered:
image

@petrihakkinen

Copy link
Copy Markdown
Contributor

Issue 1 can potentially be fixed by guarding against emphasis on line ~781:

Previously:

if( code.state == Code::NONE && c == '`' && !line.isHeading && link.state == Link::NO_LINK )`

Potential fix:

if( code.state == Code::NONE && c == '`' && !line.isHeading && link.state == Link::NO_LINK && em.state == Emphasis::NONE )

@ghostintheshell-192

Copy link
Copy Markdown

Hi, thank you for your great work!

My question: are you implementing only inline code, or also fenced code block? Your code seems to be supporting only inline code.

List of issues found:

Fenced code block — language tag is visible and rendered as code, then the following lines are rendered as NORMAL_TEXT

Input:

x = 1    

Expected: language tag discarded, x = 1 rendered as CODE
Actual: python rendered as CODE, x = 1 rendered as NORMAL_TEXT


Inline code in table cells — backtick characters appear literally; isTableRow skips all inline parsing

Input:

function description
init() initializes

Expected: init() rendered as CODE inside the cell
Actual: init() rendered as plain text with literal backticks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants