Skip to content

fix: prevent table from absorbing following shortcode as a row - #3

Merged
htnabe merged 2 commits into
mainfrom
fix/table-shortcode-blank-line
Sep 6, 2026
Merged

htnabe merged 2 commits into
mainfrom
fix/table-shortcode-blank-line

Conversation

@htnabe

@htnabe htnabe commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes a bug where a Markdown table absorbed an immediately following Hugo shortcode closing tag (e.g. {{</ table >}}) as an extra single-cell table row, because Prettier's underlying markdown parser (remark-gfm) requires a blank line to terminate a table.
  • Adds a tag-triggered GitHub Actions workflow that creates a GitHub Release with auto-generated notes, independent from the existing manual npm publish workflow.
  • Prepares the 0.0.1-rc.2 release (version bump + changelog).

Changes

  • src/features/printers/printers.ts: ensureProperBlockSpacing() now inserts a blank line between a Markdown table and a following non-table line, so the following line (e.g. a Hugo shortcode) is not absorbed as an extra table row. Added isMarkdownTableRow(), a conservative pipe-based table row detector that explicitly excludes Go template lines ({{ ... }}) and non-table pipe usage (e.g. {{ .Title | upper }}) to avoid false positives.
  • tests/suites/basic-functionality.test.js: added regression tests covering (1) the reported table/shortcode absorption bug and (2) that Go template pipelines are not misclassified as table rows.
  • .github/workflows/release.yml: new workflow, triggered on v* tag pushes, creates a GitHub Release via gh release create --generate-notes.
  • docs/development/publishing.md: documents the new tag-triggered release workflow and clarifies it is separate from the manual npm publish flow.
  • package.json / bun.lock: version bump to 0.0.1-rc.2 and routine dependency updates (@types/node, lefthook, oxlint).
  • CHANGELOG.md: added 0.0.1-rc.2 entry documenting the fix and the new release workflow.

Validation

  • bun run lint — passes
  • bun run format:check — passes
  • bun test — 59 pass, 0 fail (includes 2 new regression tests)

Risks

  • Formatted Markdown output now includes an extra blank line before any line immediately following a table when one wasn't present before (required to avoid the table absorbing that line); this changes exact output for such inputs but produces correct, GFM-compliant Markdown.
  • New tag-push workflow only creates GitHub Releases; it does not publish to npm, so no change to the existing publish process.

Checklist

  • Conventional commit(s) with gitemoji used
  • Commit granularity is meaningful
  • Tests and lint were run as appropriate
  • Documentation updated if needed

Insert a blank line between a markdown table and a following non-table
line (e.g. a Hugo shortcode closing tag) before handing content to
Prettier's markdown formatter. Without this, remark-gfm's table
extension absorbs the next non-blank line as an extra single-cell
table row when no blank line separates it from the table.

Also adds a tag-triggered GitHub Actions workflow that creates a
GitHub Release with auto-generated notes on 'v*' tag pushes, and
bumps the package version to 0.0.1-rc.2 for release.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@htnabe
htnabe requested a lite review from Copilot September 6, 2026 12:20
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new table-row detection is overly broad (treats any | line as a table row) and can introduce unintended blank-line mutations for non-table content like Go template pipelines.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR addresses a Markdown formatting edge case in the plugin’s pre-Prettier normalization step, preventing remark-gfm/Prettier from incorrectly treating a Hugo shortcode closing tag as an extra GFM table row when it immediately follows a table.

Changes:

  • Insert a blank line between a GFM table and the next non-table line during template preprocessing to avoid remark-gfm table “absorption”.
  • Add a regression test covering a table immediately followed by a closing shortcode.
  • Add a tag-push GitHub Release workflow and document it; bump version and update changelog and lockfile.
File summaries
File Description
src/features/printers/printers.ts Adds table-termination spacing logic in ensureProperBlockSpacing() plus a helper to detect table rows.
tests/suites/basic-functionality.test.js Adds regression test ensuring a closing shortcode is not reformatted into a table row.
.github/workflows/release.yml New workflow to create GitHub Releases on v* tag pushes with generated notes.
docs/development/publishing.md Documents the new tag-triggered GitHub Release workflow and its relationship to npm publishing.
package.json Bumps package version and updates dev dependency versions.
CHANGELOG.md Adds 0.0.1-rc.2 entry with the bug fix and release-workflow note.
bun.lock Updates lockfile to reflect dependency bumps.
Review details
  • Files reviewed: 6/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/features/printers/printers.ts Resolved
Tighten isMarkdownTableRow() so lines like {{ .Title | upper }} are
never treated as GFM table rows. The previous check flagged any line
containing '|', which caused ensureProperBlockSpacing() to insert
unwanted blank lines around Go template pipe expressions and other
non-table pipe usage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@htnabe
htnabe merged commit 3bc95d0 into main Sep 6, 2026
1 check passed
@htnabe
htnabe deleted the fix/table-shortcode-blank-line branch September 6, 2026 12:28
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