diff --git a/CHANGELOG.md b/CHANGELOG.md index 56d111d..a9a4aa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,11 @@ instead of version numbers. By contrast, optional arguments add parentheses: `\begin{theorem 1}` produces "Theorem (1)", and `\begin{proof}[sketch]` produces "Proof (sketch)". -* `\begin{tabular}` improvements: skip over `\&`, HTML tags/character codes, - and braced content, which makes it possible to include URLs with `&`s. +* `\begin{tabular}` improvements: + * Skip over `\&`, HTML tags/character codes, and braced content, + which makes it possible to include URLs with `&`s. + * Fix column computations when using both `\multirow` and `\multicolumn` + (in separate cells). ## 2023-11-01 diff --git a/lib/formats.coffee b/lib/formats.coffee index a8792e1..de005f5 100644 --- a/lib/formats.coffee +++ b/lib/formats.coffee @@ -304,10 +304,12 @@ latex2htmlCommandsAlpha = (tex, math) -> (for row in splitOutside body, /(?:\\\\|\[DOUBLEBACKSLASH\])/ #(?:\s*\\(?:hline|cline\s*{[^{}]*}))?/ #console.log row continue unless row.trim() + colnum = 0 "\n" + - (for col, colnum in splitOutside row, /&/ + (for col in splitOutside row, /&/ if skip[colnum] - skip[colnum] -= 1 + skip[colnum]-- + colnum++ continue align = cols[colnum] attrs = '' @@ -316,9 +318,12 @@ latex2htmlCommandsAlpha = (tex, math) -> ## entry, you must put the \multirow inside the \multicolumn" ## [http://ctan.mirrors.hoobly.com/macros/latex/contrib/multirow/multirow.pdf] if (match = /\\multicolumn\s*(\d+|{\s*(\d+)\s*})\s*(\w|{([^{}]*)})\s*{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}/.exec col)? - attrs += " colspan=\"#{match[2] ? match[1]}\"" + colspan = parseInt match[2] ? match[1], 10 + attrs += " colspan=\"#{colspan}\"" align = match[4] ? match[3] col = match[5] + else + colspan = 1 ## In HTML, rowspan means that later rows shouldn't specify s ## for that column, while in LaTeX, they are still present. if (match = /\\multirow\s*(\d+|{\s*(\d+)\s*})\s*(\*|{([^{}]*)})\s*{((?:[^{}]|{(?:[^{}]|{[^{}]*})*})*)}/.exec col)? @@ -338,6 +343,7 @@ latex2htmlCommandsAlpha = (tex, math) -> " style=\"#{style}text-align: right\"" else style + colnum += colspan "#{col}\n" ).join('') + "\n"