Skip to content
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

[Feature request] compatibility with pandoc-crossref filter #6

Closed
jpcirrus opened this issue Jul 26, 2015 · 21 comments
Closed

[Feature request] compatibility with pandoc-crossref filter #6

jpcirrus opened this issue Jul 26, 2015 · 21 comments

Comments

@jpcirrus
Copy link

It would be very helpful to get this to work with the pandoc-crossref filter. Currently the 2 don't work together.

@mb21
Copy link
Owner

mb21 commented Jul 26, 2015

So you're applying pandoc-placetable before pandoc-crossref and the following gives you a table, but it's not numbered by pandoc-crossref?

```{#tbl:label .table file="foo.csv"}
```

@jpcirrus
Copy link
Author

Yes. Taking latex output as an example: no \label is being generated for the tables e.g. this table

```{#tbl:table3 .table caption="A Placetable Table"}
Banana,8,10.00
```

results in this:

\begin{longtable}[c]{@{}lrr@{}}
\caption{A Placetable Table}\tabularnewline
% rest of table

instead of this:

\begin{longtable}[c]{@{}ll@{}}
\caption{\label{tbl:table3}A Placetable Table}\tabularnewline
% rest of table

All that needs to happen is that a fenced code block identifier starting with #tbl: needs to be become the label for pandoc-crossref to be able to reference the table.

@mb21
Copy link
Owner

mb21 commented Jul 26, 2015

Right, the Pandoc AST currently doesn't have attributes on tables. That's why the pandoc-crossref filter exists and isn't part of pandoc, see pandoc issue #813.

So there might be a way to get pandoc-placetable to write out markdown that pandoc-crossref can parse again, but it would be quite a hack as you would go cat in.md | pandoc --filter pandoc-placetable -t markdown | pandoc --filter pandoc-crossref. I would rather hope that Pandoc's Table gets Attr support.

Or modify pandoc-crossref to parse a table wrapped in a div with the id tbl:label as a table with such an id... @lierdakil ?

@lierdakil
Copy link

I'd also prefer to have Attrs on tables and whatnot, but that's, regrettably, not something that's doable in near future.

What pandoc-crossref does to emulate this missing functionality, is it parses last "word" (i.e. token without spaces) in table title as identifier in the form {#tbl:something}. But implementing that in pandoc-placetable would have its own set of challenges, I think. So going with a wrapper div seems like a reasonable option (something I was planning on anyway). One caveat though, I'm swamped at the moment, so it might take some time until I can actually get to this. Expect some of it done probably by the end of next week or so.

@jpcirrus
Copy link
Author

Thanks @mb21 and @lierdakil. I am just starting out with pandoc so am not familiar with the internals and didn't appreciate the complexity.

@mb21
Copy link
Owner

mb21 commented Jul 26, 2015

@lierdakil great, if you were planning to do wrapper divs anyhow, I think that's the best solution.

@lierdakil
Copy link

Sorry about the hold-up, but I finally got around to this.
v0.1.4.0 is available as package candidate at the moment https://hackage.haskell.org/package/pandoc-crossref-0.1.4.0/candidate. It should treat div-wrapped tables as pandoc-crossref tables with id (same goes for images and display math). One caveat is that div must contain [Plain [item]] for images/math and [table] for tables, i.e. no other content is allowed, and inline items have to be wrapped in Plain instead of Para.

@lierdakil
Copy link

I will publish package candidate when I make sure it works across all relevant configurations (i.e. when tests pass)

@mb21
Copy link
Owner

mb21 commented Aug 19, 2015

sound good, I'll close this issue here then...

@mb21 mb21 closed this as completed Aug 19, 2015
@mickley
Copy link

mickley commented Oct 3, 2015

I've tried to use pandoc-placetable with pandoc-crossref as outlined above, but it doesn't seem to work. The reference to the table using [@TBL:table4], shows up as tbl??

Below is what I've used:

```{#tbl:table4 .table header=yes caption="Table caption"}
Fruit,Price,Advantages
Bananas,$1.34,"Bright color"
Oranges,$2.10,"Oranges are orange"

@lierdakil
Copy link

Huh. I assumed pandoc-placetable generates a div to keep some attributes like id, but apparently not. You can try wrapping your code block into a div with id. That said, there is a problem with caption, which I will try to fix now.

@lierdakil
Copy link

Something like this should work with pandoc-crossref 0.1.5.3, providing it's run after pandoc-placetable.

<div id="tbl:table4">
``{.table header=yes caption="Table caption"}
Fruit,Price,Advantages
Bananas,$1.34,"Bright color"
Oranges,$2.10,"Oranges are orange"
``
</div>

[@tbl:table4]

@mickley
Copy link

mickley commented Oct 11, 2015

Ok, this works for me. I suppose this is worth noting in the readme, at least over at pandoc-crossref.

I guess a more elegant solution would have to come from pandoc-placetable unless pandoc-crossref were run first. Though for now this is fine.

@lierdakil
Copy link

@mb21, do you think you could wrap pandoc-placetable-generated tables in a div if those have id (or for that matter classes) set? Shouldn't be too hard, I think?

@mb21
Copy link
Owner

mb21 commented Oct 11, 2015

@lierdakil done: 21f16b5

@lierdakil
Copy link

👍

@mickley
Copy link

mickley commented Jan 20, 2016

@mb21 @lierdakil:

I noticed today that if I refer to a table using pandoc-crossref syntax inside of a caption from pandoc-placetable, it isn't referenced.

For example:

```{.table #tbl:table2 header=yes caption="Refer to [@tbl:table1]. "}
Col1, Col2, Col3

That's not parsed by pandoc-crossref at all, and just stays in the caption as is. I'm not sure which of you has a better chance at this or even if it's fixable, but it would be nice to refer to other tables/figures in captions.

@mickley
Copy link

mickley commented Jan 20, 2016

I should clarify by saying that the order in which the two filters run doesn't affect this either.

@mb21
Copy link
Owner

mb21 commented Jan 21, 2016

Maybe specifying pandoc-citeproc explicitly (--filter pandoc-citeproc) and making sure it is executed as the last of the three filters?

@lierdakil
Copy link

@mickley, you probably need to build pandoc-placetable with inlineMarkdown switch, so that citation is actually parsed by pandoc. Otherwise, pandoc-crossref assumes it's a raw string, and does nothing with it.

@mickley
Copy link

mickley commented Jan 21, 2016

@lierdakil Thanks, that was it. While already compiled with inlineMarkdown, I wasn't explicitly setting it as an option for that individual table. This makes good sense though.

@mb21 pandoc-citeproc doesn't factor into this at all, though it's already explicit and last in my filters.

For anyone else, the correct order of filters should be:

  • pandoc-placetable
  • pandoc-crossref
  • pandoc-citeproc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants