Skip to content

feat: Add formatter and vscode extension - #3

Merged
Fuyeors merged 10 commits into
mainfrom
feat/vscode-extension
Aug 21, 2026
Merged

feat: Add formatter and vscode extension#3
Fuyeors merged 10 commits into
mainfrom
feat/vscode-extension

Conversation

@Fuyeors

@Fuyeors Fuyeors commented Aug 21, 2026

Copy link
Copy Markdown
Member

No description provided.

Manus AI and others added 10 commits August 21, 2026 10:02
This commit introduces a VS Code language extension for Fuyeor Flavored Markdown (FFM).
It includes declarative language configuration and a comprehensive TextMate grammar covering:
- Standard FFM blocks (slide, chain, accordion, quote)
- FFM-specific inline syntax (underline, strikethrough, math, inline code)
- Common Markdown syntax mapped to standard text.html.markdown scopes
- Custom syntax tests running via Vitest

The extension is entirely declarative without a Node.js runtime component,
ensuring minimal footprint and highest performance.
This commit fixes the default editor behavior for FFM files by adding
configurationDefaults to the extension manifest:
- Enables word wrap and advanced wrapping strategy since FFM is natural
  text, not source code.
- Disables unicode ambiguous character highlights to suppress warnings
  for full-width characters like `:` commonly used in CJK documents.
- Includes the newly added examples directory in the VSIX bundle.
- Extends the Vitest suite to verify these configuration defaults.
This commit introduces a dedicated `@fuyeor/markdown-formatter` package
and integrates it into the VS Code extension as a document formatting
provider.

The formatter satisfies the requested FFM formatting rules:
- Adds spaces between CJK text and Latin letters/numbers, except inside
  protected inline code or math expressions.
- Removes trailing spaces before line breaks.
- Trims leading and trailing whitespace from the document while preserving
  intentional list indentation.
- Normalizes list indentation to a maximum of 2 spaces and removes redundant
  spacing after the marker.
- Normalizes Markdown table padding and delimiter hyphens while preserving
  alignment colons.
- Converts contiguous blocks of `>>>` deep quotes into FFM `\`\`quote` fences.
- Formats text inside FFM semantic fences (slide, quote, chain, accordion)
  while preserving their boundaries and leaving standard code blocks intact.

All rules are verified by a comprehensive Vitest suite in the new package.
The VS Code extension bundles the formatter using esbuild, retaining its
zero-dependency runtime footprint.
This commit fixes a misunderstanding of the blockquote conversion rule.
Previously, it looked for `>>>` (multiple markers on the same line).
Now, it correctly identifies contiguous Markdown blockquotes (`> `) that
span at least three lines (including empty quoted lines like `>`), and
converts the entire block into an FFM `\`\`quote` semantic fence while
preserving the original paragraph spacing.

Shorter blockquotes (1-2 lines) remain as standard Markdown `> ` quotes.
This commit fixes three formatting edge cases reported by users:
1. Prevent horizontal rules (`---`) from being misidentified and
   formatted as empty Markdown tables.
2. Ensure CJK/Latin spacing rules are correctly applied around inline
   emphasis markers (e.g., `**bold**`, `_italic_`) without disrupting
   the Markdown syntax.
3. Automatically trim whitespace around Markdown link destinations
   (e.g., `[text](  url  )` becomes `[text](url)`).

All fixes are backed by dedicated Vitest regression tests.
This commit addresses several text formatting issues and modernizes the
test suite:
- Normalizes spacing between blockquote markers and their content
  (e.g., `>    Text` becomes `> Text`).
- Ensures protected inline tokens (like inline code and math) correctly
  receive spaces when adjacent to CJK characters.
- Removes meaningless leading whitespace from ordinary text lines.
- Compresses consecutive blank lines down to a single blank line to keep
  documents concise.
- Migrates the entire formatter test suite to a language-agnostic JSON
  fixture format, ensuring tests can be reused outside of TypeScript.

All new rules are covered by the JSON fixtures and pass the Vitest suite.
This commit fixes an issue where the blank-line compressor would
accidentally discard the indentation context of nested lists, causing
them to be flattened to the root level.

The formatter now correctly tracks the current list nesting depth across
contiguous lines, preserving 2-space increments per level (e.g.,
nested bullets or numbered lists) while still compressing actual
redundant blank lines in ordinary paragraphs.
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markdown-parser-playground Error Error Aug 21, 2026 5:19pm

@Fuyeors
Fuyeors merged commit 4022d72 into main Aug 21, 2026
2 of 4 checks passed
@Fuyeors
Fuyeors deleted the feat/vscode-extension branch August 22, 2026 07:09
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.

1 participant