bids-specification icon indicating copy to clipboard operation
bids-specification copied to clipboard

[ENH] render table from TSV

Open Remi-Gau opened this issue 1 year ago • 12 comments

  • closes #644
  • relates to #1757
  • relates to #1756

rely on mkdocs plugins to render TSV


  • [x] ensure proper PDF build

Remi-Gau avatar Apr 15 '24 13:04 Remi-Gau

@yarikoptic @sappelhoff

http://127.0.0.1:8000/en/stable/longitudinal-and-multi-site-studies.html#longitudinal-and-multi-site-studies

How would this look:

image

Note that grabbing the content from the HTML (with copy-paste) gives this (where separators are one space + one tab):

session_id 	acq_time 	systolic_blood_pressure
ses-predrug 	2009-06-15T13:45:30 	120
ses-postdrug 	2009-06-16T13:45:30 	100

Remi-Gau avatar Apr 15 '24 13:04 Remi-Gau

if we are OK with this look, I could do the other TSV examples in the spec.

Remi-Gau avatar Apr 15 '24 13:04 Remi-Gau

I think this is a great improvement!

one space + one tab

why the space though 🤔

sappelhoff avatar Apr 15 '24 14:04 sappelhoff

why the space though 🤔

No idea

Remi-Gau avatar Apr 15 '24 14:04 Remi-Gau

looks neat! I would have still adjusted styling to remove even row separators visually.

re "space" -- worth checking on https://github.com/timvink/mkdocs-table-reader-plugin/issues?

how would it work for PDFs?

yarikoptic avatar Apr 15 '24 15:04 yarikoptic

how would it work for PDFs?

will add a bit of code to inject content during the pdf build

Remi-Gau avatar Apr 15 '24 15:04 Remi-Gau

if we need to add a warning for copy pasting directly from the HTML, I would suggest using mkdocs annotations:

https://squidfunk.github.io/mkdocs-material/reference/annotations/#using-annotations

Remi-Gau avatar Apr 15 '24 16:04 Remi-Gau

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.93%. Comparing base (943c20e) to head (72705c7). Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1783   +/-   ##
=======================================
  Coverage   87.93%   87.93%           
=======================================
  Files          16       16           
  Lines        1351     1351           
=======================================
  Hits         1188     1188           
  Misses        163      163           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 16 '24 08:04 codecov[bot]

PDF looks good to me:

image

Remi-Gau avatar Apr 16 '24 08:04 Remi-Gau

For the PDF could also just opt for a more verbatim rendering rather than actual tables.

Though not sure how often people will "copy paste" from the pdf.

Remi-Gau avatar Apr 16 '24 09:04 Remi-Gau

I hate to throw a towel on all of this, but I feel like moving the examples into separate files will only make the spec more difficult to contribute to. One thing we could consider is writing a custom fence formatter and write a renderer that would convert

```tsv
session_id	body_weight
ses-01	58
ses-02	59
```

into

| session_id | body_weight |
|--|--|
| ses-01 | 58 |
| ses-02 | 59 |

effigies avatar Apr 18 '24 02:04 effigies

I hate to throw a towel on all of this, but I feel like moving the examples into separate files will only make the spec more difficult to contribute to.

To be fair this was an unvoiced concern of mine when working on this, so thanks for raising it.

In any case this is not urgent so we can definitely wait before merging: moving back to draft.

In the meantime I will try to work on those fencer thing you linked to.

🤺

Remi-Gau avatar Apr 18 '24 07:04 Remi-Gau