File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ Let's format it!
6161
6262## Integration with Formatting Tools
6363
64+ See the [ examples/] ( examples/ ) directory for complete configuration files and sample markdown files demonstrating the integrations.
65+
6466### treefmt
6567
6668[ treefmt] ( https://github.com/numtide/treefmt ) is a universal code formatter that runs multiple formatters with one command.
Original file line number Diff line number Diff line change 1+ # Integration Examples
2+
3+ This directory contains example configurations and files for integrating markdown-format with various formatting tools.
4+
5+ ## Files
6+
7+ - ` treefmt.toml ` - Example configuration for treefmt
8+ - ` markdown-format-inplace.sh ` - Wrapper script for treefmt integration (makes markdown-format work in-place)
9+ - ` dprint.json ` - Example configuration for dprint
10+ - ` sample-input.md ` - Sample markdown file before formatting
11+ - ` sample-output.md ` - Sample markdown file after formatting with markdown-format
12+
13+ ## Testing the Integration
14+
15+ ### With treefmt
16+
17+ 1 . Install treefmt (https://github.com/numtide/treefmt )
18+ 2 . Copy ` treefmt.toml ` and ` markdown-format-inplace.sh ` to your project root
19+ 3 . Update the path in ` markdown-format-inplace.sh ` to point to your markdown-format binary
20+ 4 . Run ` treefmt ` to format all markdown files
21+
22+ ### With dprint
23+
24+ 1 . Install dprint (https://dprint.dev/ )
25+ 2 . Copy ` dprint.json ` to your project root
26+ 3 . Update the command path to point to your markdown-format binary
27+ 4 . Run ` dprint fmt ` to format all markdown files
28+
29+ ## Verifying the Integration
30+
31+ You can test the integration by:
32+
33+ 1 . Creating a copy of ` sample-input.md ` in your project
34+ 2 . Running your formatter (treefmt or dprint)
35+ 3 . Comparing the result with ` sample-output.md `
36+
37+ The output should match, with one sentence per line while preserving all markdown structure.
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " https://dprint.dev/schemas/v0.json" ,
3+ "exec" : {
4+ "commands" : [{
5+ "command" : " ./markdown-format/markdown-format {{file_path}}" ,
6+ "exts" : [" md" ]
7+ }]
8+ },
9+ "plugins" : [],
10+ "excludes" : [
11+ " **/*-lock.json" ,
12+ " **/node_modules" ,
13+ " **/.git"
14+ ]
15+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Wrapper script to make markdown-format work in-place for treefmt
3+ # This script takes file paths as arguments and formats them in place
4+
5+ # Adjust this path to where your markdown-format binary is located
6+ MARKDOWN_FORMAT=" ./markdown-format/markdown-format"
7+
8+ for file in " $@ " ; do
9+ if [ -f " $file " ]; then
10+ # Create a temporary file
11+ temp_file=$( mktemp)
12+ # Format the file and save to temp
13+ " $MARKDOWN_FORMAT " " $file " > " $temp_file "
14+ # Replace original file with formatted content
15+ mv " $temp_file " " $file "
16+ fi
17+ done
Original file line number Diff line number Diff line change 1+ # Sample Document
2+
3+ This is a paragraph with multiple sentences. It should be formatted with one sentence per line. This makes git diffs easier to read.
4+
5+ ## Features
6+
7+ - First item with a long description. This has multiple sentences.
8+ - Second item
9+ - Third item with more text. And even more!
10+
11+ ## Code Example
12+
13+ ``` python
14+ def hello ():
15+ print (" Hello, world!" )
16+ ```
17+
18+ Conclusion paragraph. Final thoughts here. That's all!
Original file line number Diff line number Diff line change 1+ # Sample Document
2+
3+ This is a paragraph with multiple sentences.
4+ It should be formatted with one sentence per line.
5+ This makes git diffs easier to read.
6+
7+ ## Features
8+
9+ - First item with a long description.
10+ This has multiple sentences.
11+ - Second item
12+ - Third item with more text.
13+ And even more!
14+
15+ ## Code Example
16+
17+ ``` python
18+ def hello ():
19+ print (" Hello, world!" )
20+ ```
21+
22+ Conclusion paragraph.
23+ Final thoughts here.
24+ That's all!
Original file line number Diff line number Diff line change 1+ # Example treefmt configuration for markdown-format
2+ # Place this file in your project root as treefmt.toml
3+
4+ [formatter .markdown-format ]
5+ # Path to the wrapper script that formats files in-place
6+ command = " ./markdown-format-inplace.sh"
7+ # No additional options needed
8+ options = []
9+ # Format all markdown files
10+ includes = [" *.md" ]
11+ # Optionally exclude certain files
12+ excludes = []
You can’t perform that action at this time.
0 commit comments