jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
219 stars 64 forks source link

`toc` entries are rendered in reverse, or alphabetically, sometimes. :( #1641

Closed sneakers-the-rat closed 1 week ago

sneakers-the-rat commented 1 week ago

Description

When I do this:

myst.yml

version: 1
project:
  id: 3447377e-b204-4078-8398-fcc69565b0bf
  toc:
    - file: section_one.md
    - file: section_two.md
    - file: section_three.md
site:
  template: book-theme

I get this:

Image

but also when I do this

version: 1
project:
  id: 3447377e-b204-4078-8398-fcc69565b0bf
  toc:
    - file: a.md
    - file: b.md
    - file: c.md
    - file: z.md
    - file: f.md
site:
  template: book-theme

i get this

Image

which is correct.

and in my real document which is like this

  toc:
    - file: src/index.md
    - file: src/intro/intro.md
      children:
      - file: src/intro/prior_art.md
    - file: src/implementation/implementation.md
      children:
      - file: src/implementation/spec.md
      - file: src/implementation/generators.md
      - file: src/implementation/nwb.md
    - file: src/examples/examples.md
      children:
      - file: src/examples/nwb_linkml.md
    - file: src/discussion/discussion.md

i get this

Image

which has the first entry in place but the rest reversed for each group.

but if i use a jupyter book ToC the ordering is correct

src/_toc.yml

format: jb-book
root: index
chapters:
- file: intro/intro
  sections:
  - file: intro/prior_art
- file: implementation/implementation
  sections:
  - file: implementation/spec
  - file: implementation/generators
  - file: implementation/nwb
- file: examples/examples
  sections:
  - file: examples/nwb_linkml
- file: discussion/discussion

Image

if i add logger commands at the start and end of this function for entries and pages they are both in the correct order when loaded here: https://github.com/jupyter-book/mystmd/blob/16a5e5869e10faf069f1fe2b288ffdea858d4345/packages/myst-cli/src/project/fromTOC.ts#L240

and i don't know the best way to trace through to see when it gets reversed, and i'm not sure why the alphabetical example is in the correct order but the section_one, etc. example isnt?

Proposed solution

ideally it would be in the order it's specified in!

Additional notes

rowanc1 commented 1 week ago

Do you have a small public repo of these examples? Have not seen anything like this before!

sneakers-the-rat commented 1 week ago

amazingly, when i go to reproduce one hour later, i can no longer do it where an hour ago i couldn't get it to not happen both in CI and locally. i swear i did not just make up a weird issue for no reason

this is literally what i was doing, no venv funny business (as in i am running the same binaries with the same python interpreter, same node, etc): repo:https://github.com/sneakers-the-rat/mystmd-1641-example site: https://jon-e.net/mystmd-1641-example/

so i know this is not helpful as an issue... i can close this and reopen it if it starts happening again........ truly a "computer mystery behavior" hour for me.

edit: my initial guess was the use of a Set somewhere instead of an Array, which would explain the intermittence of the problem? but i truly don't know.