I'm working on csv format to markdown, and have code something like this
document.querySelector("textarea.csv").addEventListener('input',(e) => {
const convert = e.target.value
.replaceAll(", ", " | ")
.replace(/,\n/g, " |\n| ")
.replace(/, \n/g, " |\n| ")
.replace(/ \| \n/g, " |\n| ")
.replace(/^[!\|]/g, "| ")
console.log(
convert
);
document.querySelector("textarea.markdown").value = "| " + convert;
})
But I think I missed the case to cover the line start from not "|", is there any way to check it?
The full code is here: https://codepen.io/dotku/pen/rNzOZLZ?editors=1010