Skip to content

fix: render inline code in widget lists, headings and tables - #519

Merged
neuromechanist merged 1 commit into
OpenScience-Collective:developfrom
bendichter:fix/widget-inline-code-in-lists
Sep 28, 2026
Merged

neuromechanist merged 1 commit into
OpenScience-Collective:developfrom
bendichter:fix/widget-inline-code-in-lists

Conversation

@bendichter

Copy link
Copy Markdown
Contributor

Summary

While testing the NWB community on dev, this answer rendered with literal backticks in the widget:

Required fields:

* `session_description`: Description of the experimental session
* `identifier`: Unique identifier (UUID recommended)
* `session_start_time`: Reference time for all timestamps in the file (datetime object with timezone)

Cause: renderInlineMarkdown handles bold, italics, links, URLs and citations, but not inline code. Only markdownToHtml's plain-paragraph path converted backticks, before calling it. List items, numbered items, headings and table cells call renderInlineMarkdown directly, so their inline code came out as `session_description`.

Fix:

  • renderInlineMarkdown now matches inline code alongside the other inline elements. The content is escaped and isn't parsed further, so *, ** and [1] inside code stay literal. The paragraph path now just calls renderInlineMarkdown, which removes the duplicate handling.
  • Indented list items ( * item, which models use for nested lists) now stay in the list. Before, they fell through to a paragraph showing a literal *. Nesting is flattened.

Tests

  • New frontend/test-markdown.js, in the same style as test-citation-markers.js: it runs the widget's own markdownToHtml. It covers the answer above, numbered lists, headings, table cells, escaping and non-parsing of code content, a bracketed number inside code not being linked as a citation, unchanged paragraph output, and indented items. 13 pass with the fix; 11 fail on develop.
  • Added to the frontend-tests job in test.yml and tests.yml.
  • frontend/test-citation-markers.js and frontend/test-streaming.js still pass. I ran these locally with Node because Bun isn't installed; the files use only APIs both support.
  • pytest tests/test_frontend -k 'not workspace_export': 43 passed. test_workspace_export.py needs Bun.

renderInlineMarkdown did not handle inline code; only markdownToHtml's
paragraph path converted backticks. List items, headings and table
cells therefore showed literal backticks, e.g. an NWB answer's
'* `session_description`: ...' list. Inline code is now matched in
renderInlineMarkdown (escaped, not parsed further), and paragraphs use
it directly.

Indented list items, which models use for nested lists, are now kept
in the list instead of becoming paragraphs with a literal '*'.

Adds frontend/test-markdown.js, run with Bun in the frontend-tests job.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

3 participants