Skip to content

Conversation

@cameronr
Copy link
Collaborator

@cameronr cameronr commented Oct 28, 2025

This started out as a smaller bugfix but along the way I noticed that sometimes parts were not rendering, so that's the more important issue, from: 4317d0b:

This was a subtle one and it only shows up when we're not collapsing
events so it wasn't caught by the unit tests. I've since modified the
unit tests to also run the replays without collapsing to catch bugs like
this in the future.

If the first version of a part didn't result in something being
rendered, future updates to that part would also not render anything.
This was particularly likely to happen with tools as the first version
of the part is often step-start. Because we didn't think this was a
new part, we called _replace_part_in_buffer but that exits quickly
because the part hadn't been rendered anywhere.

While we could try to call _insert_part_to_buffer in
_replace_part_in_buffer if the part hadn't been rendered, that would
miss some subtle cases around error handling so the correct fix is
consider the part new in on_part_updated if we haven't rendered it
before.

Now, onto the issue that started this PR:

I noticed that embedded codefences were screwing up our rendering. At first, I thought we needed to escape/replace them but then I realized we could use a longer codefence for our outer wrapper. I also realized that we weren't setting the markdown types correctly (markdown should be markdown not md). Setting the codefence to markdown enables render-markdown to render embedded codefences correctly.

Before:

Screenshot 2025-10-28 at 16 16 24

After (the codefence is normally hidden, I just have the cursor there to show the longer codefence and correct type)

Screenshot 2025-10-28 at 21 10 55

It seems like the markdown rendering plugins get confused by nested code
fences so we replace embedded fences with ` ` `
@cameronr cameronr force-pushed the fix/markdown-double-render branch from be49c31 to c1e625a Compare October 28, 2025 23:28
Instead of disabling embedded markdown rendering, we can use a longer
outer codefence.

It did require regenerating all of the test data.
@cameronr cameronr changed the title fix(formatter): replace embedded md codefences fix(formatter): use longer codefences Oct 29, 2025
Instead of just using the filename extension, use the neovim filetype
(with some specific overrides). Fall back to the filename extension.

This means we render our markdown sections with `markdown` as the type
instead of `md` and that enables rendering embedded codefences
correctly.

Hopefully the last fix on this :)
Seems like nightly returns text as the type for .txt files which breaks
our tests
This was a subtle one and it only shows up when we're not collapsing
events so it wasn't caught by the unit tests. I've since modified the
unit tests to also run the replays without collapsing to catch bugs like
this in the future.

If the first version of a part didn't result in something being
rendered, future updates to that part would also not render anything.
This was particularly likely to happen with tools as the first version
of the part is often `step-start`. Because we didn't think this was a
new part, we called `_replace_part_in_buffer` but that exits quickly
because the part hadn't been rendered anywhere.

While we could try to call `_insert_part_to_buffer` in
`_replace_part_in_buffer` if the part hadn't been rendered, that would
miss some subtle cases around error handling so the correct fix is
consider the part new in `on_part_updated` if we haven't rendered it
before.
@cameronr cameronr changed the title fix(formatter): use longer codefences fix(renderer): parts not rendering, markdown types Oct 29, 2025
@cameronr cameronr changed the title fix(renderer): parts not rendering, markdown types fix(renderer): occasional parts rendering, markdown types Oct 29, 2025
@cameronr
Copy link
Collaborator Author

@sudo-tee This one is probably a little urgent so would love a review when you have time.

Copy link
Owner

@sudo-tee sudo-tee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great fix.

Thanks you for this

There is a small conflict with main, once it's resolved I will merge

@sudo-tee
Copy link
Owner

@cameronr

I'm sorry I think I messed up the conflict resolution with the github UI.

@cameronr
Copy link
Collaborator Author

cameronr commented Oct 29, 2025

no worries, i can take a look in a few hours. fwiw, the GH UI merges have let me down before so I've stopped doing merges there.

also, if you'd rather i can just rebase my changes on main and resubmit the pr?

@sudo-tee
Copy link
Owner

no worries, i can take a look in a few hours. fwiw, the GH UI merges have let me down before so I've stopped doing merges there.

also, if you'd rather i can just rebase my changes on main and resubmit the pr?

Yes that would probably be easier to just rebase and drop the merge commit I did

@cameronr cameronr closed this Oct 29, 2025
@cameronr cameronr deleted the fix/markdown-double-render branch November 6, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants