mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Drive spreadsheet table not converting to Markdown table
This commit is contained in:
parent
6cb2b68b22
commit
4654f076f5
@ -619,18 +619,19 @@ export default Ember.Component.extend({
|
|||||||
_detectTable(text) {
|
_detectTable(text) {
|
||||||
if (text.endsWith("\n")) {
|
if (text.endsWith("\n")) {
|
||||||
text = text.substring(0, text.length - 1);
|
text = text.substring(0, text.length - 1);
|
||||||
let rows = text.split("\r").join("").split("\n");
|
}
|
||||||
|
|
||||||
if (rows.length > 1) {
|
let rows = text.split("\r").join("").split("\n");
|
||||||
const columns = rows.map(r => r.split("\t").length);
|
|
||||||
const isTable = columns.reduce((a, b) => a && columns[0] === b && b > 1);
|
|
||||||
|
|
||||||
if (isTable) {
|
if (rows.length > 1) {
|
||||||
const splitterRow = [...Array(columns[0])].map(() => "---").join("\t");
|
const columns = rows.map(r => r.split("\t").length);
|
||||||
rows.splice(1, 0, splitterRow);
|
const isTable = columns.reduce((a, b) => a && columns[0] === b && b > 1);
|
||||||
|
|
||||||
return "|" + rows.map(r => r.split("\t").join("|")).join("|\n|") + "|\n";
|
if (isTable) {
|
||||||
}
|
const splitterRow = [...Array(columns[0])].map(() => "---").join("\t");
|
||||||
|
rows.splice(1, 0, splitterRow);
|
||||||
|
|
||||||
|
return "|" + rows.map(r => r.split("\t").join("|")).join("|\n|") + "|\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user