-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added-support-for-table-parser #42
base: master
Are you sure you want to change the base?
Conversation
Hello I made this code in Javascript, it is not very optimized I know, but it works well for tables
For the HTML class, i use Bootstrap, but you can define your own css
|
yes your code is fine @KevinCeyland for the same parsing i have raised the pr ,for giving the support of the |
Any ETA for merge it? |
I created a solution that works with headings too: type TableBlock = {
type: 'table';
data: {
withHeadings: boolean;
content: string[][];
};
}
function tableParser(block: TableBlock): string {
const tableData = block.data.content;
const withHeadings = block.data.withHeadings;
let tableHTML = '<table>';
tableData.forEach((row, rowIndex) => {
if (withHeadings && rowIndex === 0) {
tableHTML += '<thead>';
}
tableHTML += '<tr>';
row.forEach((cellData, cellIndex) => {
if (withHeadings && rowIndex === 0) {
tableHTML += '<th>' + cellData + '</th>';
} else {
tableHTML += '<td>' + cellData + '</td>';
}
});
tableHTML += '</tr>';
if (withHeadings && rowIndex === 0) {
tableHTML += '</thead>';
}
});
tableHTML += '</table>';
return tableHTML;
} |
Up |
As per my observation table type support was not there. And in this PR , i have given the support for the table type.
Also i have tested this by modifying test.js file .