norvig / paip-lisp

Lisp code for the textbook "Paradigms of Artificial Intelligence Programming"
MIT License
7.12k stars 699 forks source link

Markdown tables #136

Open HM0880 opened 2 years ago

HM0880 commented 2 years ago

I am working through converting the table screenshots into Markdown tables. I have converted the Chapter 7 table [1]. The remaining chapters are Chapters 11, 12, 15, 16, 17, 18, 21, and 23.

I do not know how to handle the table caption. MarkedJS has table captions as an open feature request [2]. Let me know how table captions for PAIP should be done, and I will update my edits before submitting a pull request.

[1] https://github.com/HM0880/paip-lisp/commit/51bf6b1df85bcca0421d0a78b7aa3dedb36c5e67 [2] https://github.com/markedjs/marked/issues/980#issuecomment-360575399

pronoiac commented 2 years ago

Hmm, looks like this is an open and unanswered question! I think I'd put the caption as free text under the table, maybe with a leading "Table: ".

It looks like Github isn't rendering the table right now, missing the header row - adding an empty row like | | | appears to help. Adding that sort of empty row also might render better than the rows of |---|.

Sorry that you're stumbling on an unclear spot in Markdown parsers! Thanks for editing and the column alignment!

HM0880 commented 2 years ago

@pronoiac

Happy to help! PAIP is a great book.

Updates:

[1] https://github.com/HM0880/paip-lisp/blob/main/docs/chapter7.md [2] https://github.com/HM0880/paip-lisp/blob/main/docs/chapter7.md?plain=1#L118

pronoiac commented 2 years ago

#f0010 isn't great; other chapters have that, and that might confuse things in Pandoc, which concatenates all the chapters in its workflow. How about #figure-07-1? Mimicking the links for footnotes, something like:

The program is summarized in [figure 7.1](#figure-07-1).

<a id="figure-07-1"></a>
[table]
Figure 7.1: Glossary for the STUDENT Program

Though if you opted to skip the link because it's right there, it's understandable.

norvig commented 2 years ago

I've found that markdown rendering for tables on github has been problematic. I'm glad you are trying to sort this out. Thank you!

HM0880 commented 2 years ago

@pronoiac

I have chosen to follow the PAIP book convention: do not reference "close" figures (i.e., figures 23.1 and 23.2) but do reference "far away" figures (i.e., figure 23.3). (I wrote this choice in https://github.com/HM0880/paip-lisp/commit/95da5307703c5247562ca7546f36c2724d677db2)

I have a question about the screenshots of the tables: the screenshots are referenced in the PAIP-safari.md document [1] (e.g., line 5631 references figure 04-02 [2]). I have been deleting the screenshots as I update the tables. Should I keep the screenshots so that existing scripts for export to different formats still work?

[1] https://github.com/norvig/paip-lisp/blob/main/PAIP-safari.md [2] https://github.com/norvig/paip-lisp/blob/main/docs/images/chapter4/f04-02.jpg

pronoiac commented 2 years ago

This reminds me that I should probably document how I go from the epub to the chapter markdown files, but not today...

For the purposes of review, I might hold off on deleting the table gifs, for a separate PR. If you've already deleted them, don't worry about it; I can compare to a local branch.

The chapter markdown files are where almost all editing happens; the book-long markdown file isn't kept in sync. When I've generated epub or pdf files, it was from the chapters. And when I replaced formulae with vector images, I deleted the old gifs; it makes it easier to skim pixelated images and see what could be redone and fixed up.

Have you had any issues with legibility on the scan?

HM0880 commented 2 years ago

For the purposes of review, I might hold off on deleting the table gifs, for a separate PR. If you've already deleted them, don't worry about it; I can compare to a local branch.

OK. I added the table images back to my repo to make the future merge request easier.

The chapter markdown files are where almost all editing happens; the book-long markdown file isn't kept in sync. When I've generated epub or pdf files, it was from the chapters. And when I replaced formulae with vector images, I deleted the old gifs; it makes it easier to skim pixelated images and see what could be redone and fixed up.

There are also some other images (e.g., [1]) that could be drawn with something like Mermaid [2]. Would redrawing these sorts of images be useful?

Have you had any issues with legibility on the scan?

No, the tables have been very legible. I also have a print copy of the book so I can compare against the printed version if needed.

EDIT: Figure 12.1 has a make-= in the "Auxiliary Functions" section, but the = is not readable at all.

[1] Chapter 2 tree image [2] https://mermaid-js.github.io/mermaid/

pronoiac commented 2 years ago

There are also some other images (e.g., [1]) that could be drawn with something like Mermaid [2]. Would redrawing these sorts of images be useful?

It's a good idea! (And totally a separate branch, btw.) It's been somewhere on my todo list for ages. I could see using Mermaid or Graphviz for some figures, and perhaps ~draw.io~ diagrams.net for more general drawing.

(I have a lot of bookmarks and thoughts about diagrams, but I won't dump them all here.)

HM0880 commented 2 years ago

I like Graphviz for its longevity, but the dynamic scaling of images produced by a Javascript solution is appealing.

I created Issue #139 for more discussion.

pronoiac commented 2 years ago

I've been making lots of small edits, and that can tangle up PRs with merge conflicts, and that makes me want to aim at shorter-lived branches. Is there anything that would help with the effort for turning images into markdown tables?

HM0880 commented 2 years ago

Is there anything that would help with the effort for turning images into markdown tables?

My initial plan was to do a PR for all the tables at once, but I plan to do a PR now for the tables that I have completed to keep up-to-date with the repo.

Edit: Opened PR https://github.com/norvig/paip-lisp/pull/148

pronoiac commented 2 years ago

I'm thinking about making new ebooks in a month or so. How's it going?

HM0880 commented 2 years ago

Hi @pronoiac, sorry for the delay. After mid-August, I would have more time to work on the tables.