Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MarkdownTableCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2824,7 +2824,7 @@ EditResult convertDelimitedToTable(const std::string &text)
{
EditResult result;
// Tabs at the edges delimit empty TSV cells and must reach the parser.
const std::string &value = text;
const std::string value = text.compare(0, 3, "\xEF\xBB\xBF") == 0 ? text.substr(3) : text;
const char delimiter = detectDelimiter(value);
if (!hasDelimitedStructure(value, delimiter))
{
Expand Down
35 changes: 35 additions & 0 deletions test-fixtures/markdown-table-core-golden.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
{
"schemaVersion": 2,
"conversion": [
{
"name": "leading bom quoted csv",
"input": "\uFEFF\"Name\",\"City\"\n\"Bob\",\"Paris\"",
"lines": ["| Name | City |", "| ---- | ----- |", "| Bob | Paris |"]
},
{
"name": "leading bom quoted tsv crlf",
"input": "\uFEFF\"Name\"\t\"City\"\r\n\"Bob\"\t\"Paris\"",
"lines": ["| Name | City |", "| ---- | ----- |", "| Bob | Paris |"]
},
{
"name": "leading bom multiline quoted csv header",
"input": "\uFEFF\"First\nName\",City\nBob,Paris",
"lines": ["| First Name | City |", "| ---------- | ----- |", "| Bob | Paris |"]
},
{
"name": "leading bom empty tsv edge cells",
"input": "\uFEFF\tName\t\n\tBob\t",
"lines": ["| | Name | |", "| --- | ---- | --- |", "| | Bob | |"]
},
{
"name": "leading bom preserves internal bom",
"input": "\uFEFFName,City\nBo\uFEFFb,Paris",
"lines": ["| Name | City |", "| ---- | ----- |", "| Bo\uFEFFb | Paris |"]
},
{
"name": "leading bom quoted csv tab is data",
"input": "\uFEFF\"Name\tAlias\",City\nBob,Paris",
"lines": ["| Name\tAlias | City |", "| ---------- | ----- |", "| Bob | Paris |"]
},
{
"name": "leading bom escaped pipe contract",
"input": "\uFEFFName,Note\nBob,\"a|b\\|c\"",
"lines": ["| Name | Note |", "| ---- | ------- |", "| Bob | a\\|b\\|c |"]
},
{
"name": "quoted tabs in later records preserve established tsv",
"input": "Title, notes\nA\tfoo\nB\tbar\n\t\"x\ty\"",
Expand Down