mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00

- added csv-replacer - changed highlghted-code plugin: each replacer extracts what he need from the data-extra attribute now - changed CHANGELOG.md Co-authored-by: Erik Michelson <github@erik.michelson.eu>
8 lines
336 B
TypeScript
8 lines
336 B
TypeScript
export const parseCsv = (csvText: string, csvColumnDelimiter: string): string[][] => {
|
|
const rows = csvText.split('\n')
|
|
if (!rows || rows.length === 0) {
|
|
return []
|
|
}
|
|
const splitRegex = new RegExp(`${csvColumnDelimiter}(?=(?:[^"]*"[^"]*")*[^"]*$)`)
|
|
return rows.filter(row => row !== '').map(row => row.split(splitRegex))
|
|
}
|