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

Date handling in Markdown export #875

Open
cskeeters opened this issue Jun 30, 2024 · 6 comments
Open

Date handling in Markdown export #875

cskeeters opened this issue Jun 30, 2024 · 6 comments

Comments

@cskeeters
Copy link
Contributor

If a cell has a number representing a date and a label (for future E <c-d>), the cell of the markdown exported table outputs the label instead of the formatted date and appears to have two years in it. I'd prefer the formatted date as show to the user in sc-im.

In the example:

  • A1 was entered with \3/5/2024, Enter, <c-d>
  • B1 was entered with =@now
  • C1 was entered with =@now, Enter, :valueize

The same date format was applied to all three dates. (:format \"d%b-%Y\")

date-mkd.sc

# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
# You almost certainly shouldn't edit it.

newsheet "Sheet1"
movetosheet "Sheet1"
offscr_sc_cols 0
offscr_sc_rows 0
nb_frozen_rows 0
nb_frozen_cols 0
nb_frozen_screenrows 0
nb_frozen_screencols 0
leftstring A0 = "Date"
leftstring B0 = "Now"
leftstring C0 = "Value"
label A1 = "3/5/2024"
let A1 = 1709618400
fmt A1 "d%b-%Y"
let B1 = @now
fmt B1 "d%b-%Y"
let C1 = 1719769640
fmt C1 "d%b-%Y"
goto C0

date-mkd.mkd

| Date       | Now        | Value      |
|------------|------------|------------|
| 3/5/202424 |   Jun-2024 |   Jun-2024 |
@marrs
Copy link

marrs commented Jul 2, 2024

I wasn't able to reproduce your issue. Instead I got the following date-mkd.mkd on running e! mkd:

| Date           | Now        | Value      |
|----------------|------------|------------|
| ************** |   Jul-2024 |   Jun-2024 |

Is there anything else I should do to reproduce your result?

@cskeeters
Copy link
Contributor Author

cskeeters commented Jul 2, 2024

I'm running on MacOS Sonoma 14.3.1 (23D60). I installed sc-im with:

brew install --head sc-im

After some further testing, if I make the A column wider (30fl) within sc-im, and re-export the markdown, I get the label centered and the formatted date on the right. It just dawned on me that there might be a correlation between the width of the columns in the sheet and the exported table. That's something worth noting. I had previously guessed it would calculate the widest exported text for that column and make it that width.

Within sc-im, the cell only displays the formatted date on the right. I think that's what I would prefer to see in the mkd output.

| Date                                   | Now        | Value      |
|----------------------------------------|------------|------------|
|                3/5/2024       Mar-2024 |   Jul-2024 |   Jun-2024 |

@marrs
Copy link

marrs commented Jul 2, 2024

I can't reproduce that either! I just see the formatted date in A1.

Btw, I'm not a maintainer or anything. I was just troubleshooting a possibly related bug of my own.

@cskeeters
Copy link
Contributor Author

To be clear, I see only the formatted date in A1 from within sc-im. In the mkd file that results from e! mkd, I see a centered text with the date label and the formatted date on the right of the cell that would correspond to A1. You don't see that?

@marrs
Copy link

marrs commented Jul 2, 2024

Ah, I misunderstood. Yes, I do see that. In that case, it might be related to my bug. I can fix it with the following patch:

diff --git a/src/file.c b/src/file.c
index 40c0cfd..fafa2d3 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1541,7 +1541,7 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
                     }
 
                     // If a string exists
-                    if ((*pp)->label) {
+                    if ((*pp)->v == '\0' && (*pp)->label) {
                         strcpy(text, (*pp)->label);
                         align = 1;                                // right alignment
                         if ((*pp)->flags & is_label) {            // center alignment

which is the same as what I did for #879. FYI @andmarti1424

@marrs
Copy link

marrs commented Jul 2, 2024

I think the not-enough-room formatting is also a bug. The fact there was enough room for the date when viewing in sc-im directly suggests there should be enough room to show it in the markdown version.

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

No branches or pull requests

3 participants