Skip to content

Fix paragraph_close collapsing paragraph spacing (#15)#17

Merged
thesmallstar merged 1 commit into
mainfrom
fix/paragraph-spacing-issue-15
May 23, 2026
Merged

Fix paragraph_close collapsing paragraph spacing (#15)#17
thesmallstar merged 1 commit into
mainfrom
fix/paragraph-spacing-issue-15

Conversation

@thesmallstar
Copy link
Copy Markdown
Owner

Summary

  • paragraph_close returned a single \n, so two markdown paragraphs rendered as adjacent lines in Slack instead of separated by a blank line. This diverged from the JS reference slackify-markdown, which separates paragraphs with \n\n.
  • Fix: emit \n\n from paragraph_close for normal paragraphs, keep \n for tight-list paragraphs (markdown-it tags those with token.hidden).
  • render() now normalizes trailing whitespace once (rstrip("\n") + "\n"), so the document always ends with exactly one trailing \n regardless of which token last emitted. This also fixes a sibling divergence where a heading at end of document trailed with \n\n while JS produces \n.

Closes #15.

Verified against JS reference

Built and ran the upstream JS slackify-markdown against the same inputs; outputs for paragraphs, headings, tight lists, loose lists, and definitions now match. Pre-existing divergences for zero-width-space inline markers, hard-break \ preservation, and list→heading block separation are out of scope for this issue.

Test plan

  • uv run pytest tests/test_convert.py — 49 passed
  • Updated tests assert JS-reference outputs (test_definitions, test_headings, test_heading_with_bold, test_heading_with_italic, two loose-list tests)
  • test_complex_markdown regenerated from actual output
  • Manually verified paragraph spacing renders correctly in Slack via webhook

paragraph_close returned a single \n, so two paragraphs in the source
markdown rendered as adjacent lines in Slack instead of separated by a
blank line. This diverged from the JS reference slackify-markdown,
which separates paragraphs with \n\n.

Changes:
- paragraph_close now returns \n\n for normal paragraphs and \n for
  tight-list paragraphs (markdown-it marks those with token.hidden).
- render() trims trailing newlines and re-adds a single \n so the
  document ends with exactly one trailing \n, matching the JS lib.
  This also fixes a sibling divergence where headings at end of
  document trailed with \n\n.
- Tests updated to assert the JS-reference outputs; test_complex_markdown
  regenerated from actual output.
@thesmallstar thesmallstar merged commit 22d6d7e into main May 23, 2026
7 checks passed
thesmallstar added a commit that referenced this pull request May 24, 2026
* Bump to 0.2.3, refresh uv.lock, add Python 3.14 support

- version: 0.2.2 -> 0.2.3 to release the paragraph spacing fix from #17
- uv.lock: regenerate to current lockfile schema (revision 1 -> 3);
  same dependency graph, just metadata refresh from a newer uv
- classifiers: add Python 3.14 (released Oct 2025)

Tests pass on the default toolchain and on Python 3.14 explicitly
(verified via `uv run --python 3.14 pytest`).

Note: requires-python is still ">=3.8" to avoid breaking existing
installs, though Python 3.8 (EOL Oct 2024) and 3.9 (EOL Oct 2025)
are past upstream support. Dropping them is a follow-up.

* Add Python 3.14 to CI test matrix

Mirrors the classifier addition in pyproject.toml so CI actually
exercises tests against Python 3.14 on every PR.
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.

Bug: paragraph_close emits single newline, collapsing paragraph spacing

1 participant