ryanfox / sphinx-markdown-tables

A markdown table plugin for Sphinx
GNU General Public License v3.0
59 stars 15 forks source link

No table output to a `.tex` file from an `.md` file for Sphinx `make latexpdf` to make PDF table #3

Open johncrossland opened 6 years ago

johncrossland commented 6 years ago

I can use sphinx-markdown-tables successfully for HTML from Sphinx make html but not make latexpdf. I would like an update to do this instead of needing to work around it by converting .md tables to .rst tables manually, using Markdown2PDF and making PDFs from .md separately using md2pdf. We need Sphinx to make PDF as well as HTML. We want our developers to be able to author in .md as easily as they'd write a README.md to obtain accurate documentation from them in GitHub code repositories. We don't want to ask developers to author in .rst as it'd reduce how much accurate documentation we'd get.

ryanfox commented 6 years ago

Currently only HTML is supported, but pull requests are welcome.

jkmacc-LANL commented 3 years ago

I'm not familiar with the internals of Sphinx; what changes would need to be made? I see where you've made a function to convert markdown tables to HTML here and connected it as a callback after Sphinx reads the source file. If I had a function that could convert Markdown tables to LaTeX syntax, how do I connect it as a callback to Sphinx for when I want the make latexpdf rule?

gaodingpan commented 3 years ago

I would love to have this functionality as well, any way I could help? Though, I am not familiar with the Sphinx.

ryanfox commented 3 years ago

@jkmacc-LANL @gaodingpan You would need to find out programmatically whether Sphinx was called with make html or make latexpdf, I don't know if that's available in the source-read event. The list of events Sphinx supports is here.

The general Sphinx documentation on writing extensions is here, though I find them a little impenetrable.

The callback is registered here.

gaodingpan commented 3 years ago

@jkmacc-LANL @gaodingpan You would need to find out programmatically whether Sphinx was called with make html or make latexpdf, I don't know if that's available in the source-read event. The list of events Sphinx supports is here.

The general Sphinx documentation on writing extensions is here, though I find them a little impenetrable.

The callback is registered here.

figured out how to determine the current target, just import sys and check if "latexpdf" is in sys.argv will do it. Next I will try to output correct latex table format from markdown input

It seems that directly rendering the table to output latex table texts into blocks is not working ,any advice?

I used pytablereader and pytablewriter to generate latex codes, but the code is treated as raw text.

This is the output: image

I found kind of a hack to it, I will create the table output to rst but append "```eval_rst" before the table to make sphinx evaluate as rst source. it worked for now.

Dzordzu commented 3 years ago

Hi. Any updates on this?

annanyearian commented 2 years ago

To anyone who finds themselves here, it seems as though using myst is a better path to follow and has table support built-in. A quick test of myst compiled simple markdown tables nicely to PDF output.