Skip to content

Investigate and fix frontend rendering issues for headers with numbered prefixes - #354

Merged
malibio merged 4 commits into
mainfrom
feature/issue-353-fix-header-rendering
Oct 27, 2025
Merged

malibio merged 4 commits into
mainfrom
feature/issue-353-fix-header-rendering

Conversation

@malibio

@malibio malibio commented Oct 27, 2025

Copy link
Copy Markdown
Collaborator

Closes #353

malibio and others added 4 commits October 27, 2025 22:54
## Problem
Headers with numbered prefixes like "### 1. Maintainability" were being
rendered as HTML ordered lists (`<ol><li>Maintainability</li></ol>`)
instead of plain text "1. Maintainability".

## Root Cause
- marked.js with GFM enabled was detecting the "1. " pattern as an
  ordered list, even within header node content
- This caused extra line breaks and incorrect HTML structure

## Solution
Added custom `list()` renderer to marked-config.ts that:
- Disables HTML list generation (`<ol>`, `<ul>` tags)
- Preserves list markers as plain text ("1. ", "2. ", "- ")
- Maintains the original text formatting

## Testing
- Verified in browser that "### 1. Maintainability" now renders as
  "1. Maintainability" (plain text) instead of `<ol><li>` HTML
- Confirmed no `<ol>` or `<li>` tags in DOM

## Documentation
- Updated marked-config.ts header comments to document:
  - List rendering behavior
  - GFM table header bold rendering (intended behavior)

Fixes #353

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Set min-height to 1.5rem (24px) for both textarea and empty view divs
- This matches the line-height:1.5 that makes textarea naturally 24px tall
- Previously: textarea was 24px, empty view div was 20px (4px difference)
- Now: both are 24px, preventing nodes below from shifting on edit/view toggle

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add codespan renderer to marked-config.ts for backtick syntax
- Style inline code to match code blocks (muted bg, padding, monospace font)
- Inline code uses <code class="markdown-code-inline"> element
- Example: `code` renders with same visual style as code-block nodes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
## Changes

### 1. Add Regression Tests (Critical - Addresses #353 Acceptance Criteria)
- Add comprehensive test suite for list rendering behavior
- Test that "1. Text" remains plain text (not converted to <ol>)
- Test headers with numbered prefixes (#353 specific case)
- Test unordered lists, task lists, and various number formats
- Add tests for inline code rendering
- All 20 tests in marked-config.test.ts pass

### 2. Architectural Documentation (Important)
- Document why list renderer disables HTML list generation globally
- Explain NodeSpace's semantic node type architecture
- Note future consideration for conditional list rendering
- Clarify relationship with /ordered-list slash command

### 3. Enhanced GFM Documentation (Nice-to-have)
- Explain why GFM is enabled despite semantic node types
- Document trade-offs and design decisions
- Reference Issue #350 for context on marked.js adoption

### 4. Improved Code Comments (Nice-to-have)
- Clarify recursive parsing of list item tokens
- Explain preservation of markers as plain text vs <li> tags

### 5. CSS Consolidation Documentation (Nice-to-have)
- Document .markdown-code as legacy from markdown-utils.ts
- Add TODO for future consolidation with .markdown-code-inline
- Prevent confusion about duplicate styling

## Testing
- marked-config.test.ts: 20/20 tests pass
- Quality checks: 0 errors, 0 warnings
- All acceptance criteria for #353 now met

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

Investigate and fix frontend rendering issues for headers with numbered prefixes

1 participant