GPT 4 Turbo Markdown and rendering issue

Only tested this on GPT 4 Turbo API

When I request a table in markdown, the result is indeed a nice table in Markdown.
The renderer (in my case “markdown-it”: “^14.0.0”) cannot render it because GPT places the markdown between code block fences (```).

I tried to fix it by disabling the fence option (.disable(‘fence’) but this results in a nice table but also in the codeblock fence being rendered

Did someone come across the same issue and found a fix or workaround?

Hi,

Why not strip the ```'s from the output with a regex or even just a string replace prior to rendering?

2 Likes

That’s actually undesired AI production, not what would be expected.

The AI might have decided that you wanted a table that you could use elsewhere, and not a table that you wanted to see, depending on how you asked for markdown.

If you just ask for table (and I’ve found it better to go by columns and rows in specification) it should still be markdown.

Testing to see if gpt-4-1106 misbehaves — works as expected.

Untitled

1 Like

Tx, thought about that but that would take away the probability to render stuff that is supposed to be between codeblock fences

Tx, I will test this. My challenge is that it is an enduser that will request the table. I will probably have to explain in the system prompt that tables should be send as rows and columns

I think it very unlikely to have markdown blocks inside of tables… not saying that’s not going to happen, you could have a bit of logic that looks for the ``` and then checks for table markers, something that would not filter the backticks if there is no table markers found until the closing set of ```'s perhaps?

1 Like

You don’t need to describe the table as piecemeal as I show, but the AI also can’t read your mind if you have some expectations.