Skip to content

Commit

Permalink
master fix: parse markdown table error on has special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 30, 2023
1 parent 5e0b59a commit 195e245
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/Lib/Parser/DBMdTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ public function parse(string $mdTable): DBTable
$dbt->setSource($mdTable);

$lines = array_values(
array_filter(
explode("\n", trim($mdTable))
)
array_filter(explode("\n", trim($mdTable)), function ($line) {
return trim($line) !== '';
})
);

// $table = trim($lines[0], '# ');
[$tableComment, $tableName] = array_filter(explode(' ', trim($lines[0], '`:#\' ')));

// parse first line: "### 应用表(app)"
$first = trim(trim($lines[0]), '))`:#\' ');
$first = str_replace(['(', ''], ' ', $first);
[$tableComment, $tableName] = array_filter(explode(' ', $first));
$tableName = trim($tableName, '` ');
$titleLine = trim($lines[1], '| ');
$colNumber = count(explode('|', $titleLine));
Expand Down

0 comments on commit 195e245

Please sign in to comment.