SQLite Forum

Support for Markdown formatted table output from a query
> 4. For markdown mode, should it escape characters that have special meaning to markdown, like |, [, ', and *

In list-mode the `.separator` ocurrence is not being escaped, when it's part of a value string. For example, string value that includes a comma, pipe-char, single-quote, double-quote.

In quote-mode (or SQL-mode), by default all strings are quoted between single-quotes, any in-string single-quote is escaped (doubled).

In csv-mode, an in-string column `.separator` causes the string-value to be double-quoted.  An in-string double-quote is escaped (doubled).

I didn't check html-mode, as it's must be following the HTML escaping rules.

So, if Markdown is to be a separate mode, then for practical purposes the special in-string chars need to be escaped. The question is what is the full set of __special chars__ to escape?

From the extended syntax link mentioned earlier:

> Formatting Text in Tables
>You can format the text within tables. For example, you can add links, code (words or phrases in backticks (\`) only, not code blocks), and emphasis.
>You can't add headings, blockquotes, lists, horizontal rules, images, or HTML tags.
>Escaping Pipe Characters in Tables
>You can display a pipe (`|`) character in a table by using its HTML character code (`|`).

Not sure why the second paragraph in the quote above got emphasized...

- - - - -

create table x(id, val);
insert into x(id, val) values(1,'text'),(2,',comma'),(3,'|pipe'), (4,'''s-quote'),(5,'"d-quote');

.mode list 
select * from x;

.separator ,
select * from x;