Skip to content

Commit b59fb70

Browse files
committed
chore: update VSCode settings and README formatting
### CHANGES - Add files to `.prettierignore` for consistency - Enable `formatOnSave` in VSCode settings - Set default formatter to Prettier in VSCode - Configure ESLint validation for JavaScript and TypeScript - Adjust README code formatting for clarity - Ensure newline at end of `index.js` file
1 parent 3c47539 commit b59fb70

4 files changed

Lines changed: 55 additions & 25 deletions

File tree

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ coverage
44
*.log
55
.git
66
.github/workflows/*.yml
7+
pnpm-lock.yaml
8+
package-lock.json
9+
cspell.json

.vscode/settings.json

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
{
22
"markdownlint.config": {
33
"MD033": {
4-
"allowed_elements": [
5-
"br",
6-
"div",
7-
"img"
8-
]
4+
"allowed_elements": ["br", "div", "img"]
95
}
106
},
11-
"markdownlint.lintWorkspaceGlobs": [
12-
"**/*.md"
13-
]
7+
"markdownlint.lintWorkspaceGlobs": ["**/*.md"],
8+
"editor.formatOnSave": true,
9+
"editor.defaultFormatter": "esbenp.prettier-vscode",
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll.eslint": "explicit"
12+
},
13+
"editor.tabSize": 2,
14+
"editor.insertSpaces": true,
15+
"editor.detectIndentation": false,
16+
"files.trimTrailingWhitespace": true,
17+
"files.insertFinalNewline": true,
18+
"prettier.configPath": "./.prettierrc",
19+
"eslint.validate": [
20+
"javascript",
21+
"javascriptreact",
22+
"typescript",
23+
"typescriptreact"
24+
],
25+
"eslint.workingDirectories": ["."],
26+
"[javascript]": {
27+
"editor.defaultFormatter": "esbenp.prettier-vscode"
28+
},
29+
"[json]": {
30+
"editor.defaultFormatter": "esbenp.prettier-vscode"
31+
},
32+
"[markdown]": {
33+
"editor.defaultFormatter": "esbenp.prettier-vscode",
34+
"files.trimTrailingWhitespace": false
35+
}
1436
}

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,17 @@ console.log(sectionMarkdown);
151151
### Advanced Usage
152152

153153
```javascript
154-
import { MarkdownTreeParser, createParser, extractSection } from 'markdown-tree-parser';
154+
import {
155+
MarkdownTreeParser,
156+
createParser,
157+
extractSection,
158+
} from 'markdown-tree-parser';
155159

156160
// Create parser with custom options
157161
const parser = createParser({
158-
bullet: '-', // Use '-' for lists
159-
emphasis: '_', // Use '_' for emphasis
160-
strong: '__' // Use '__' for strong
162+
bullet: '-', // Use '-' for lists
163+
emphasis: '_', // Use '_' for emphasis
164+
strong: '__', // Use '__' for strong
161165
});
162166

163167
// Extract all sections at level 2
@@ -185,8 +189,7 @@ const codeBlocks = parser.selectAll(tree, 'code');
185189

186190
// Custom search
187191
const customNode = parser.findNode(tree, (node) => {
188-
return node.type === 'heading' &&
189-
parser.getHeadingText(node).includes('API');
192+
return node.type === 'heading' && parser.getHeadingText(node).includes('API');
190193
});
191194

192195
// Transform content
@@ -198,7 +201,9 @@ parser.transform(tree, (node) => {
198201

199202
// Get document statistics
200203
const stats = parser.getStats(tree);
201-
console.log(`Document has ${stats.wordCount} words and ${stats.headings.total} headings`);
204+
console.log(
205+
`Document has ${stats.wordCount} words and ${stats.headings.total} headings`
206+
);
202207

203208
// Generate table of contents
204209
const toc = parser.generateTableOfContents(tree, 3);
@@ -241,7 +246,7 @@ for (let i = 0; i < sections.length; i++) {
241246
#### Constructor
242247

243248
```javascript
244-
new MarkdownTreeParser(options = {})
249+
new MarkdownTreeParser((options = {}));
245250
```
246251

247252
#### Methods
@@ -272,18 +277,18 @@ The library supports powerful CSS-like selectors for searching:
272277

273278
```javascript
274279
// Element selectors
275-
parser.selectAll(tree, 'heading') // All headings
276-
parser.selectAll(tree, 'paragraph') // All paragraphs
277-
parser.selectAll(tree, 'link') // All links
280+
parser.selectAll(tree, 'heading'); // All headings
281+
parser.selectAll(tree, 'paragraph'); // All paragraphs
282+
parser.selectAll(tree, 'link'); // All links
278283

279284
// Attribute selectors
280-
parser.selectAll(tree, 'heading[depth=1]') // H1 headings
281-
parser.selectAll(tree, 'heading[depth=2]') // H2 headings
282-
parser.selectAll(tree, 'link[url*="github"]') // Links containing "github"
285+
parser.selectAll(tree, 'heading[depth=1]'); // H1 headings
286+
parser.selectAll(tree, 'heading[depth=2]'); // H2 headings
287+
parser.selectAll(tree, 'link[url*="github"]'); // Links containing "github"
283288

284289
// Pseudo selectors
285-
parser.selectAll(tree, ':first-child') // First child elements
286-
parser.selectAll(tree, ':last-child') // Last child elements
290+
parser.selectAll(tree, ':first-child'); // First child elements
291+
parser.selectAll(tree, ':last-child'); // Last child elements
287292
```
288293

289294
## 🧪 Testing

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ export async function generateTOC(markdown, maxLevel = 3, options = {}) {
7474
const parser = new MarkdownTreeParser(options);
7575
const tree = await parser.parse(markdown);
7676
return parser.generateTableOfContents(tree, maxLevel);
77-
}
77+
}

0 commit comments

Comments
 (0)