feat: Add formatter and vscode extension - #3
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.