Skip to content

Commit 94e9cbc

Browse files
committed
fix: broken table rendering
1 parent b2dda5b commit 94e9cbc

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/tags.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export const tagHandlers: Record<string, TagHandler> = {
191191
},
192192
table: {
193193
enter: ({ node, state }) => {
194+
state.tableRenderedTable = false
194195
if (isInsideTableCell(node)) {
195196
return '<table>'
196197
}
@@ -204,7 +205,6 @@ export const tagHandlers: Record<string, TagHandler> = {
204205
if (isInsideTableCell(node)) {
205206
return '<thead>'
206207
}
207-
state.tableNeedsThead = true
208208
},
209209
exit: ({ node }) => isInsideTableCell(node) ? '</thead>' : undefined,
210210
},
@@ -222,8 +222,8 @@ export const tagHandlers: Record<string, TagHandler> = {
222222
}
223223

224224
// Handle header row separator
225-
if (state.tableNeedsThead) {
226-
state.tableNeedsThead = false
225+
if (!state.tableRenderedTable) {
226+
state.tableRenderedTable = true
227227

228228
// Ensure we have alignments for all columns
229229
const alignments = state.tableColumnAlignments!
@@ -253,10 +253,6 @@ export const tagHandlers: Record<string, TagHandler> = {
253253
return '<th>'
254254
}
255255

256-
if (state.tableNeedsThead !== false) {
257-
state.tableNeedsThead = true
258-
}
259-
260256
// Handle alignment
261257
const align = node.attributes?.align?.toLowerCase()
262258
if (align) {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export interface MdreamRuntimeState extends Partial<MdreamProcessingState> {
128128
options?: HTMLToMarkdownOptions
129129

130130
/** Table processing state */
131-
tableNeedsThead?: boolean
131+
tableRenderedTable?: boolean
132132
tableCurrentRowCells?: number
133133
tableColumnAlignments?: string[]
134134
}

0 commit comments

Comments
 (0)