chrisaga / hk-pandoc-filters

My Lua filters for Pandoc document processor
https://chrisaga.github.io/hk-pandoc-filters/
MIT License
4 stars 1 forks source link

Table Rule is not Showing Up When There Is a Colspan at the First Cell #2

Closed shoaibjo closed 2 years ago

shoaibjo commented 2 years ago

Hey,

I found out that when colspan is at the beginning of the table it miss to add table rule into it. I will provide .md file with command that I am using.

Mytable.md looks like this

# Testing
this is to test font

>  pandoc -s --pdf-engine=xelatex --metadata-file=pandoc-metadata-block.yml --from=markdown-markdown
_in_html_blocks --lua-filter=parse-html.lua --lua-filter tables-rules.lua mytable.md -o mytable.pdf

## Example with Issue on it

<html>
<table>
    <col width="15%" />
    <col width="30%" />
    <col width="15%" />
    <col width="30%" />
    <thead>
        <tr>
            <th colspan=4>Something as header</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="4"> This is to test If coll span is at the beginning of a table</td>
        </tr>
        <tr>
            <td>Tester:</td>
            <td>None</td>
            <td>Tester2:</td>
            <td>None</td>
        </tr>
         <tr>
            <td colspan="4"> This is to test If coll span is at the beginning of a table</td>
        </tr>
        <tr>
            <td>DTC</td>
            <td colspan=3>Here are some data</td>
        </tr>
        <tr>
            <td colspan="4"> This is to test If coll span is at the beginning of a table</td>
        </tr>
    </tbody>
</table>
</html>

My .yml file is

---
standalone: true

toc: true
geometry:
  - top=2cm
  - bottom=2cm
  - left=1.5cm
  - right=1.5cm

tables-vrules: true
tables-hrules: true
---

and this is parse-html.lua which is not relate to this issue I am using this to just convert html in markdwon

function RawBlock (raw)
    return raw.format:match 'html'
      and pandoc.read(raw.text, 'html').blocks
      or raw
  end

The result of this code looks like this which miss the table rule at the begining and end of table

image

Please let me know if you can help me with this or if table-rules.lua filter needs to update in order to have this

I am using latest version of filter and it already helped me a lot so good job on it.

chrisaga commented 2 years ago

I confirm there is something wrong here. I have perform more investigations to figure out how easily fixable it is.

chrisaga commented 2 years ago

Well it was nasty but easily fixable. Please @shoaibjo chek that it's OK for you

shoaibjo commented 2 years ago

I confirm there is something wrong here. I have perform more investigations to figure out how easily fixable it is.

Yeah, your right @chrisaga it was an easy fix but still it I appreciate your investigation and time on it.

New change solved the issue and everything looks good to me. I am happy that this filter covers more complex tables structure.

chrisaga commented 2 years ago

New change solved the issue and everything looks good to me. I am happy that this filter covers more complex tables structure.

You are welcome. It was originally aimed to process simple tables (pandoc markdown) and you made it go farther ;-) There may be other issues since it's only a patch of the latex code generated by Pandoc. Feel free to report them.

A more robust solution would be to code a whole table writer in lua but: