{"id":39935643,"url":"https://github.com/jdmonaco/mdformat-space-control","last_synced_at":"2026-03-02T03:08:08.767Z","repository":{"id":332327892,"uuid":"1111686333","full_name":"jdmonaco/mdformat-space-control","owner":"jdmonaco","description":"An mdformat plugin that tightens list, separates them with empty lines, and applies EditorConfig indentation settings.","archived":false,"fork":false,"pushed_at":"2026-02-02T02:04:11.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-02T11:36:40.260Z","etag":null,"topics":["mdformat"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdmonaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-07T12:55:12.000Z","updated_at":"2026-02-02T02:04:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jdmonaco/mdformat-space-control","commit_stats":null,"previous_names":["jdmonaco/mdformat-space-control"],"tags_count":8,"template":false,"template_full_name":"jdmonaco/mdformat-tight-lists","purl":"pkg:github/jdmonaco/mdformat-space-control","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmonaco%2Fmdformat-space-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmonaco%2Fmdformat-space-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmonaco%2Fmdformat-space-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmonaco%2Fmdformat-space-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdmonaco","download_url":"https://codeload.github.com/jdmonaco/mdformat-space-control/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdmonaco%2Fmdformat-space-control/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29991312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mdformat"],"created_at":"2026-01-18T18:34:51.866Z","updated_at":"2026-03-02T03:08:08.763Z","avatar_url":"https://github.com/jdmonaco.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mdformat-space-control\n\n[![Build Status][ci-badge]][ci-link]\n[![PyPI version][pypi-badge]][pypi-link]\n\nAn [mdformat](https://github.com/executablebooks/mdformat) plugin that provides unified control over Markdown spacing:\n\n- **EditorConfig support**: Configure list indentation via `.editorconfig` files\n- **Tight list formatting**: Automatically removes unnecessary blank lines between list items\n- **Frontmatter spacing**: Normalizes spacing after YAML frontmatter (works with [mdformat-frontmatter](https://github.com/butler54/mdformat-frontmatter))\n- **Consecutive blank line normalization**: Limits runs of 3+ empty lines to a maximum of 2\n- **Trailing whitespace removal**: Strips trailing whitespace outside code blocks\n- **Escaped link repair**: Fixes malformed multi-line links from web-clipped content\n- **Smart dash conversion**: Converts `--` to en-dash (–) and `---` to em-dash (—), preserving code blocks and inline code\n- **Wikilink preservation**: Handles Obsidian-style `[[links]]`, `[[links|aliases]]`, `[[page#heading]]`, `[[page#^blockid]]`, and `![[embeds]]`\n- **Explicit line breaks**: Converts soft breaks to hard breaks (`\\` + newline) so source line breaks render visually in all Markdown renderers\n\n## Installation\n\n```bash\npip install mdformat-space-control\n```\n\nOr with [pipx](https://pipx.pypa.io/) for command-line usage:\n\n```bash\npipx install mdformat\npipx inject mdformat mdformat-space-control\n```\n\n## Usage\n\nAfter installation, mdformat will automatically use this plugin:\n\n```bash\nmdformat your-file.md\n```\n\n### EditorConfig Support\n\nCreate an `.editorconfig` file in your project:\n\n```ini\n# .editorconfig\nroot = true\n\n[*.md]\nindent_style = space\nindent_size = 4\n```\n\nNested lists will use the configured indentation:\n\n**Before:**\n```markdown\n- Item 1\n  - Nested item\n- Item 2\n```\n\n**After (with 4-space indent):**\n```markdown\n- Item 1\n    - Nested item\n- Item 2\n```\n\n### Tight List Formatting\n\nLists with single-paragraph items are automatically formatted as tight lists:\n\n**Before:**\n```markdown\n- Item 1\n\n- Item 2\n\n- Item 3\n```\n\n**After:**\n```markdown\n- Item 1\n- Item 2\n- Item 3\n```\n\nMulti-paragraph items preserve loose formatting:\n\n```markdown\n- First item with multiple paragraphs\n\n  Second paragraph of first item\n\n- Second item\n```\n\n### Frontmatter Spacing\n\nWhen used with [mdformat-frontmatter](https://github.com/butler54/mdformat-frontmatter), this plugin removes blank lines between the frontmatter closing delimiter and the first content block:\n\n**Before:**\n```markdown\n---\ntitle: My Document\n---\n\n\n# Introduction\n```\n\n**After:**\n```markdown\n---\ntitle: My Document\n---\n# Introduction\n```\n\nInstall both plugins for this feature:\n\n```bash\npip install mdformat-space-control mdformat-frontmatter\n```\n\n### EditorConfig Properties\n\n| Property | Status | Notes |\n|----------|--------|-------|\n| `indent_style` | Supported | `space` or `tab` for list indentation |\n| `indent_size` | Supported | Number of spaces per indent level |\n| `tab_width` | Supported | Used when `indent_size = tab` |\n\n### Python API\n\nWhen using the Python API, you can set the file context for EditorConfig lookup:\n\n```python\nimport mdformat\nfrom mdformat_space_control import set_current_file\n\nset_current_file(\"/path/to/your/file.md\")\ntry:\n    result = mdformat.text(markdown_text, extensions={\"space_control\"})\nfinally:\n    set_current_file(None)\n```\n\n### Smart Dash Conversion\n\nMarkdown dash sequences are automatically converted to their Unicode equivalents:\n\n- `--` → en-dash (–, U+2013)\n- `---` → em-dash (—, U+2014)\n\n**Before:**\n```markdown\nThe result---unexpected as it was---changed everything.\nPages 10--20 of the report.\n```\n\n**After:**\n```markdown\nThe result—unexpected as it was—changed everything.\nPages 10–20 of the report.\n```\n\nDashes are preserved inside fenced code blocks and inline code spans. Thematic breaks (`---`) and frontmatter delimiters are not affected. Sequences of 4+ dashes are left unchanged.\n\n### Wikilink Preservation\n\nObsidian-style wikilinks are preserved during formatting:\n\n```markdown\nLink to [[another note]] or [[note|with alias]].\nEmbed an image: ![[photo.jpg]]\nLink to heading: [[note#section]]\nBlock reference: [[note#^blockid]]\n```\n\nWikilinks inside markdown link text are correctly handled without duplication:\n\n```markdown\n[![[image.jpg]]](http://example.com)\n```\n\n### Explicit Line Breaks\n\nSoft breaks (plain newlines within paragraphs) are converted to hard breaks (backslash + newline). This makes source line breaks explicit so they render visually regardless of the Markdown renderer's line-break strictness setting. The conversion applies to paragraphs, list items, and blockquotes.\n\n**Before:**\n```markdown\nThis is a paragraph with\na soft line break in the source.\n```\n\n**After:**\n```markdown\nThis is a paragraph with\\\na hard line break in the output.\n```\n\n\u003e **Note:** Without a GFM table parser, markdown-it treats pipe tables as paragraphs\n\u003e containing soft breaks, which causes backslashes to appear at the end of table rows.\n\u003e Install `mdformat-gfm` to enable proper table parsing and avoid this issue\n\u003e (see [Compatible Plugins](#compatible-plugins)).\n\n## Compatible Plugins\n\nThis plugin is tested to work alongside:\n\n- [mdformat-frontmatter](https://github.com/butler54/mdformat-frontmatter) - YAML frontmatter parsing\n- [mdformat-simple-breaks](https://github.com/csala/mdformat-simple-breaks) - Normalizes thematic breaks to `---`\n- [mdformat-gfm](https://github.com/hukkin/mdformat-gfm) - GFM table parsing (prevents hard breaks from being inserted into pipe table rows)\n\nFor formatting files in an **Obsidian vault**, the recommended install is:\n\n```bash\npip install mdformat-space-control mdformat-frontmatter mdformat-gfm\n```\n\nNote: Wikilink support is built-in; `mdformat-wikilink` is not needed.\n\n## Development\n\n```bash\n# Install dependencies\nuv sync\n\n# Run tests\nuv run python -m pytest\n\n# Run with coverage\nuv run python -m pytest --cov=mdformat_space_control\n```\n\n## License\n\nMIT - see LICENSE file for details.\n\n[ci-badge]: https://github.com/jdmonaco/mdformat-space-control/actions/workflows/tests.yml/badge.svg?branch=main\n[ci-link]: https://github.com/jdmonaco/mdformat-space-control/actions/workflows/tests.yml\n[pypi-badge]: https://img.shields.io/pypi/v/mdformat-space-control.svg\n[pypi-link]: https://pypi.org/project/mdformat-space-control\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdmonaco%2Fmdformat-space-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdmonaco%2Fmdformat-space-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdmonaco%2Fmdformat-space-control/lists"}