GithubHelp home page GithubHelp logo

Comments (21)

mickley avatar mickley commented on September 27, 2024 2

@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

from pandoc-placetable.

mb21 avatar mb21 commented on September 27, 2024

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"}
```

from pandoc-placetable.

jpcirrus avatar jpcirrus commented on September 27, 2024

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.

from pandoc-placetable.

mb21 avatar mb21 commented on September 27, 2024

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 ?

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

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.

from pandoc-placetable.

jpcirrus avatar jpcirrus commented on September 27, 2024

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

from pandoc-placetable.

mb21 avatar mb21 commented on September 27, 2024

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

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

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.

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

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

from pandoc-placetable.

mb21 avatar mb21 commented on September 27, 2024

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

from pandoc-placetable.

mickley avatar mickley commented on September 27, 2024

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"

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

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.

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

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]

from pandoc-placetable.

mickley avatar mickley commented on September 27, 2024

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.

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

@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?

from pandoc-placetable.

mb21 avatar mb21 commented on September 27, 2024

@lierdakil done: 21f16b5

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

👍

from pandoc-placetable.

mickley avatar mickley commented on September 27, 2024

@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.

from pandoc-placetable.

mickley avatar mickley commented on September 27, 2024

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

from pandoc-placetable.

mb21 avatar mb21 commented on September 27, 2024

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

from pandoc-placetable.

lierdakil avatar lierdakil commented on September 27, 2024

@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.

from pandoc-placetable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.