@aljazmc/syntax 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # > syntax
2
2
 
3
3
  Shared, dependency-free scanner and recursive descent parser for JavaScript,
4
- TypeScript, JSX and JSON, bundled into `@aljazmc/formatero` and `@aljazmc/lintero`, and published for their
4
+ TypeScript, JSX, JSON and Markdown, bundled into `@aljazmc/formatero` and `@aljazmc/lintero`, and published for their
5
5
  types.
6
6
 
7
7
  ```ts
@@ -16,3 +16,18 @@ Invalid sources throw `ParseError` with the position of the problem.
16
16
 
17
17
  `Walker.children(node)` lists the child nodes of a node in source order, and
18
18
  `Lines` turns offsets into 1-based lines and columns, for messages.
19
+
20
+ Markdown is parsed like CommonMark, with GitHub's tables, task list items
21
+ and strikethrough:
22
+
23
+ ```ts
24
+ import { isMarkdown, parseMarkdown } from "@aljazmc/syntax";
25
+
26
+ isMarkdown("README.md"); // true
27
+ const root = parseMarkdown("# Title\n\n- [x] done\n");
28
+ // root.children: a Heading and a List, with their offsets and lines
29
+ ```
30
+
31
+ Blocks have offsets into the source and 1-based lines, and keep what a
32
+ formatter needs to print them as written, like the indentation of each
33
+ line. Inlines have offsets into the text of their block.