Skip to content

Standardize Markdown rendering and heading spacing with a CommonMark/GFM and Primer baseline #16

Open

Description

@BinaryOutlook

Problem and intended outcome

The same Markdown file should communicate familiar heading hierarchy, paragraph grouping and table structure when opened in Binary Markdown and other common readers. The current editor adds substantial gaps between otherwise ordinary blocks, so authors can get a misleading impression of how their document will read elsewhere.

Adopt CommonMark/GFM as the interpretation target and GitHub Primer Markdown styling as the default visual baseline. The goal is equivalent meaning and a consistent reading rhythm across supported readers; fonts, viewport size and reader-selected themes can still affect the final appearance.

Reproduction document

The complete example formerly kept locally as docs/testing/Basic Formatting Test.md is preserved below. Recreate it in a temporary file to reproduce the issue; it does not need to be committed to main.

## 1. Summary

**Alpha Bravo Charlie.** 

Delta:

- Echo

## 2. Breakdown of Fox

| Golf | Hotel | India | Juliet   |
| ---- | ----- | ----- | -------- |
| Kilo | Lima  | Mike  | November |

October
Rendered demonstration using GitHub's own Markdown styling

1. Summary

Alpha Bravo Charlie.

Delta:

  • Echo

2. Breakdown of Fox

Golf Hotel India Juliet
Kilo Lima Mike November

October

  1. Open the sample in Binary Markdown and Typora, or compare it with the rendered demonstration above and VS Code's built-in Markdown preview.
  2. Compare the first heading, its following bold paragraph, the paragraph/list transition, the second heading and its table.
  3. For measurements, use the same body font size, zoom and usable content width. The original side-by-side comparison was qualitative; its application versions and zoom settings were not recorded.
  4. Add additional separator blank lines between a heading and its following paragraph. These should not create extra visible paragraphs or increase the rendered gap.

Observed behaviour and evidence

Assessed source: 74bd061c6be43a292704875f864f13404c2a0db0, package version 0.2.1. No tracked source modifications were present; the only local untracked file was the reproduction document.

A browser probe using this revision's production editor JavaScript and CSS confirmed the following. This is separate from verification of the exact installed VS Code extension shown in the user's comparison.

Area Observed Interpretation
Separator blank lines The example produces six empty <p><br></p> blocks in addition to its seven content blocks. Ordinary block separators become visible spacing content, unlike CommonMark's rendering model.
Page top spacing The production editor has 100px top padding. A layout choice that contributes to the large opening gap.
Headings Both sample headings are H2; with a 16px body in the Night theme they render at 24px. Other themes override heading sizes and margins independently. Preserve the H2 meaning and standardize default heading proportions and spacing.
Table layout In the reported comparison, Binary Markdown's table is compact with centred headers; Typora's is wider with left-aligned headers. The sample specifies neither width nor explicit column alignment, so these differences alone are presentation choices.
Explicit table alignment A separate :---, :---:, ---: probe renders body cells left/centre/right but all headers centred. Serialization changes explicit left alignment :--- to unspecified ---. Author-specified alignment needs to apply consistently and survive saving.

Relevant source: blank-line handling, table rendering, table serialization, page layout, and heading styles and theme overrides.

Proposed default appearance

A heading should be visually associated with the content it introduces, with greater separation from the preceding section. At a default body size of 16px, use the following baseline:

Element Target
Body text 16px, line height 1.5
H1 / H2 / H3 / H4 32px / 24px / 20px / 16px
Heading line height 1.25
Heading top / bottom margins 24px / 16px
Ordinary paragraph separation 16px
First content block No additional top margin
Document top padding Start at 32px and adapt to the viewport

The heading and block-spacing values follow Primer. The proposed 32px page padding is a product choice, not a Markdown requirement. These values describe CSS spacing; visible distances also depend on line boxes, borders and heading padding. Adjacent margins must produce the intended gap without accidental double counting. Define shared layout values and predictable scaling when the user changes the base font size.

Default colour themes should share the same typography and spacing baseline. Optional compact/spacious reading preferences can adjust density explicitly. Record any migration of existing theme behaviour and preserve user-selected font-size settings.

Use left alignment as the default for unspecified table headers, honour explicit GFM column alignment for both headers and body cells, and define responsive table sizing without treating full-width tables as a Markdown requirement.

Scope and acceptance criteria

Prioritize separator blank-line interpretation and preservation of explicit alignment, then apply the shared heading/paragraph layout. Retaining source whitespace for editing must not require treating every separator line as a visible document paragraph. Preserve intentional hard breaks, whitespace inside code and the structural meaning of blank lines in lists.

  • The sample renders as two H2 headings, three paragraphs, one single-item unordered list and one table, without six extra visible empty paragraphs.
  • Additional separator blank lines between a heading and ordinary paragraph do not enlarge the displayed gap. Source whitespace can still be retained for round-trip fidelity.
  • Heading-to-paragraph, heading-to-list and heading-to-table transitions follow the documented baseline; the first heading has no extra top margin.
  • Default colour themes share the agreed spacing and heading scale; supported font-size and viewport changes remain readable and predictable.
  • Explicit left/centre/right table alignment applies to both header and body cells and survives an unrelated edit, save and reopen, including a header-only table.
  • Viewing, changing theme or resizing the reading area does not modify Markdown. Editing and saving preserve block structure, hard breaks, list nesting, links and code whitespace.
  • Enter, Backspace, caret movement, selection, undo/redo and source/visual switching remain correct around headings, separators, lists and tables; do not rely only on hiding placeholder paragraphs with CSS.
  • Focused parsing/round-trip tests and production-CSS layout checks cover the example. Compare it with Typora, GitHub file rendering and VS Code preview using recorded settings, then verify in the native VS Code host.
  • HTML/PDF output retains the intended structure and omits editor-only caret placeholders; document any deliberate print-layout differences.

Broader CommonMark/GFM conformance is an ongoing target. Passing this example alone does not establish full parser compliance. Treat math, Mermaid, footnotes and other extensions as separately documented compatibility surfaces.

Related: #5 — Numbered-list continuation paragraphs are detached and renumbered on save. Changes to blank-line handling must account for list structure.

References

Activity

  1. added
    bug
    enhancement
    on Sep 18, 2026
  2. BinaryOutlook commented on Sep 25, 2026

    @BinaryOutlook
    OwnerAuthor

    Fresh main check on 2026-09-25: clean source 41ea238a99aea72b197fa33dc1001bd9ef09a0e5, package version 0.4.0, freshly generated standalone Chromium editor on macOS arm64. These are browser/host-message observations, not installed VS Code filesystem saves or export-reader results.

    • The exact reproduction Markdown in this issue (without a terminal newline) produced 7 content blocks and 6 extra <p><br></p> paragraphs. Appending one terminal newline produced a seventh empty paragraph. This confirms the spacing case remains on current main.
    • First \nSecond\n\nTail rendered as separate paragraphs rather than a two-space hard break. After editing only Tail to Tail!, the outgoing edit and save payloads were First\nSecond\n\nTail!\n; the authored two spaces were lost.
    • The header-only GFM table | Cost |\n| ---: | displayed a centered header without an explicit alignment style. After an unrelated edit, the outgoing save contained | --- |, losing the right-alignment marker. This exercises the issue's existing header-only alignment acceptance criterion.

    The full 1,078-check browser suite passed on the same revision with no retries; these examples show gaps in that suite, not a conflict with its result. The immediate next regression cases are the exact issue sample, a terminal-newline variant, two-space hard breaks, and a header-only aligned table through an unrelated edit and save. Keep the parser, DOM, serializer, and export contracts coordinated as described in the issue.

  3. BinaryOutlook commented on Sep 27, 2026

    @BinaryOutlook
    OwnerAuthor

    PR #80 audit update: simple quote hard breaks still change on edit

    Remaining P2 behavior: the candidate improves ordinary paragraph and block separation, but editing a simple blockquote still drops authored hard-break syntax. Keep this case within this issue's hard-break preservation scope.

    Tested source: ffbdad524d393aa783760f4829cb995d8b9d6405, 2026-09-27; unmodified production editor fixture, Node 24.21.0, Chrome 154.0.8037.57 on macOS ARM64. The following is browser DOM/outgoing-save evidence, not a native filesystem-save or export-reader check. Focused comparison reproduced the loss on baseline 41ea238a99aea72b197fa33dc1001bd9ef09a0e5 too.

    The first content line below ends with two spaces:

    > Alpha  
    > Beta

    Append ! to Beta and save. The outgoing Markdown is:

    > Alpha
    > Beta!

    The HTML-break alternative > Alpha<br>Beta similarly becomes > Alpha followed by > Beta!, losing its explicit hard break. The quote's styling can conceal the semantic difference, so compare source and an independent renderer rather than only visual spacing.

    The simple quote renderer bypasses the paragraph hard-break contract; the quote serializer trims prose-line tails. Add quote-specific hard-break, edit, undo, source-switch and native save/reopen regressions. This evidence does not claim that every acceptance criterion in #16 is either fixed or still failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions