60 | | ^---
61 | |
62 | = expected end of input, "*", unquoted string, regex, quoted string, or "^"
63 | '''
64 |
65 |
66 | [expect."block with matcher"]
67 | cli_args = ['> class']
68 | output = '''
69 | span | > ""']
76 | output = '''
77 |
78 | '''
--------------------------------------------------------------------------------
/tests/md_cases/select_link.toml:
--------------------------------------------------------------------------------
1 | [given]
2 | md = '''
3 | This text has both [an inline link](https://example.com/inline) and a [referenced link][1]. It also has an image:
4 |
5 | 
6 |
7 | [1]: https://example.com/referenced
8 | '''
9 |
10 |
11 | [expect."select all"]
12 | cli_args = ['[]()', '--link-format=inline']
13 | output = '''
14 | [an inline link](https://example.com/inline)
15 |
16 | -----
17 |
18 | [referenced link](https://example.com/referenced)'''
19 |
20 |
21 | [expect."select link by text"]
22 | cli_args = ['[an inline]()', '--link-format=inline']
23 | output = '''
24 | [an inline link](https://example.com/inline)'''
25 |
26 |
27 | [expect."select link by url"]
28 | cli_args = ['[]("/referenced")', '--link-format=inline']
29 | output = '''
30 | [referenced link](https://example.com/referenced)'''
31 |
32 |
33 | [expect."select image"]
34 | cli_args = ['![]()', '--link-format=inline']
35 | output = '''
36 | '''
37 |
38 |
39 | [expect."chained"]
40 | cli_args = ['[inline]() | [](example.com)']
41 | output = '''
42 | [an inline link][1]
43 |
44 | [1]: https://example.com/inline
45 | '''
46 |
--------------------------------------------------------------------------------
/tests/md_cases/select_lists.toml:
--------------------------------------------------------------------------------
1 | [given]
2 | md = '''
3 | # Ordered
4 |
5 | 2. two (note: starting count at 2!)
6 | 3. three
7 |
8 | # Unordered
9 |
10 | - a point
11 | - another point
12 |
13 | # Tasks
14 |
15 | - [ ] an incomplete task
16 | - [x] a completed task
17 |
18 | 1. [ ] ordered tasks are possible, too
19 | '''
20 |
21 |
22 | [expect."select ordered"]
23 | cli_args = ['1.']
24 | output = '''
25 | 2. two (note: starting count at 2!)
26 |
27 | -----
28 |
29 | 3. three
30 | '''
31 |
32 |
33 | [expect."select unordered"]
34 | cli_args = ['-']
35 | output = '''
36 | - a point
37 |
38 | -----
39 |
40 | - another point
41 | '''
42 |
43 |
44 | [expect."select all ordered tasks"]
45 | cli_args = ['- [?]'] # note: space between the - and [ is required
46 | output = '''
47 | - [ ] an incomplete task
48 |
49 | -----
50 |
51 | - [x] a completed task
52 | '''
53 |
54 |
55 | [expect."select ordered task by text"]
56 | cli_args = ['- [?] incomplete'] # note: space between the - and [ is required
57 | output = '''
58 | - [ ] an incomplete task
59 | '''
60 |
61 |
62 | [expect."select incomplete ordered tasks"]
63 | cli_args = ['- [ ]']
64 | output = '''
65 | - [ ] an incomplete task
66 | '''
67 |
68 |
69 | [expect."select completed ordered tasks"]
70 | cli_args = ['- [x]']
71 | output = '''
72 | - [x] a completed task
73 | '''
74 |
75 |
76 | [expect."select unordered tasks"]
77 | cli_args = ['1. [?]']
78 | output = '''
79 | 1. [ ] ordered tasks are possible, too
80 | '''
81 |
82 |
83 | [expect."chained"]
84 | cli_args = ['- a point | - a point']
85 | output = '''
86 | - a point
87 | '''
88 |
--------------------------------------------------------------------------------
/tests/md_cases/select_paragraphs.toml:
--------------------------------------------------------------------------------
1 | [given]
2 | md = '''
3 | Hello, world.
4 |
5 | > Paragraph within a block quote.
6 |
7 | This paragraph has _inline_ **formatting**.
8 | '''
9 |
10 |
11 | [expect."all"]
12 | cli_args = ["P:"]
13 | output = '''
14 | Hello, world.
15 |
16 | -----
17 |
18 | Paragraph within a block quote.
19 |
20 | -----
21 |
22 | This paragraph has _inline_ **formatting**.
23 | '''
24 |
25 |
26 | [expect."all but with explicit all-matcher"]
27 | cli_args = ["P: *"]
28 | output = '''
29 | Hello, world.
30 |
31 | -----
32 |
33 | Paragraph within a block quote.
34 |
35 | -----
36 |
37 | This paragraph has _inline_ **formatting**.
38 | '''
39 |
40 |
41 | [expect."select within a block quote"]
42 | cli_args = ["P: block"]
43 | output = '''
44 | Paragraph within a block quote.
45 | '''
46 |
47 |
48 | [expect."matcher ignores inline formatting"]
49 | cli_args = ["P: has inline"]
50 | # The markdown is "has _inline_", but the emphasis formatting is ignored for matching. It's still used for output.
51 | output = '''
52 | This paragraph has _inline_ **formatting**.
53 | '''
54 |
55 |
56 | [expect."no colon after p"]
57 | cli_args = ["P *"]
58 | expect_success = false
59 | output = ''
60 | output_err = '''Syntax error in select specifier:
61 | --> 1:1
62 | |
63 | 1 | P *
64 | | ^---
65 | |
66 | = expected valid query
67 | '''
68 |
69 |
70 | [expect."space before colon"]
71 | cli_args = ["P : *"]
72 | expect_success = false
73 | output = ''
74 | output_err = '''Syntax error in select specifier:
75 | --> 1:1
76 | |
77 | 1 | P : *
78 | | ^---
79 | |
80 | = expected valid query
81 | '''
82 |
83 |
84 | [expect."chained"]
85 | cli_args = ['P: hello | P: world']
86 | output = '''
87 | Hello, world.
88 | '''
--------------------------------------------------------------------------------
/tests/md_cases/select_sections.toml:
--------------------------------------------------------------------------------
1 | [given]
2 | md = '''
3 | # Alpha
4 |
5 | My first section.
6 |
7 | ## Sub-section
8 |
9 | Hello, world.
10 |
11 | # Bravo
12 |
13 | My second section.
14 | '''
15 |
16 |
17 | [expect."select top-level section"]
18 | cli_args = ["# alpha"]
19 | output = '''
20 | # Alpha
21 |
22 | My first section.
23 |
24 | ## Sub-section
25 |
26 | Hello, world.
27 | '''
28 |
29 |
30 | [expect."select subsection"]
31 | cli_args = ["# sub"]
32 | output = '''
33 | ## Sub-section
34 |
35 | Hello, world.
36 | '''
37 |
38 |
39 | [expect."select all sections"]
40 | # note: This selects all the doc's contents, but not as a single doc: each top-level header is its own selection, so the
41 | # output separates them with a thematic break.
42 | cli_args = ["#"]
43 | output = '''
44 | # Alpha
45 |
46 | My first section.
47 |
48 | ## Sub-section
49 |
50 | Hello, world.
51 |
52 | -----
53 |
54 | # Bravo
55 |
56 | My second section.
57 | '''
58 |
59 |
60 | [expect."chained"]
61 | cli_args = ['# bravo | # bravo']
62 | output = '''
63 | # Bravo
64 |
65 | My second section.
66 | '''
67 |
--------------------------------------------------------------------------------
/tests/md_cases/select_tables.toml:
--------------------------------------------------------------------------------
1 | [given]
2 | md = '''
3 | Are you ready for a table?
4 |
5 | | Name | Description |
6 | |:----:|-------------|
7 | | Foo | Not a fizz |
8 | | Bar | Not a buzz |
9 | | Barn | Big, red. | And this is an extra column |
10 | | Fuzz |
11 |
12 | Note that the "Barn" row has an extra column, and the "Fuzz" row is missing one.
13 | '''
14 |
15 |
16 | [expect."table not normalized by default"]
17 | cli_args = [""]
18 | output = '''
19 | Are you ready for a table?
20 |
21 | | Name | Description |
22 | |:----:|-------------|
23 | | Foo | Not a fizz |
24 | | Bar | Not a buzz |
25 | | Barn | Big, red. | And this is an extra column |
26 | | Fuzz |
27 |
28 | Note that the "Barn" row has an extra column, and the "Fuzz" row is missing one.
29 | '''
30 |
31 |
32 | [expect."select all table cells normalizes"]
33 | cli_args = [":-: * :-:"]
34 | output = '''
35 | | Name | Description | |
36 | |:----:|-------------|-----------------------------|
37 | | Foo | Not a fizz | |
38 | | Bar | Not a buzz | |
39 | | Barn | Big, red. | And this is an extra column |
40 | | Fuzz | | |'''
41 |
42 |
43 | [expect."select only name"]
44 | # note: "Name" has an 'a', "Description" doesn't. There are other rows that do contain 'a' in the Description column,
45 | # but the first matcher only checks the header cells (by design).
46 | cli_args = [":-: a :-:"]
47 | output = '''
48 | | Name |
49 | |:----:|
50 | | Foo |
51 | | Bar |
52 | | Barn |
53 | | Fuzz |'''
54 |
55 |
56 | [expect."select only description"]
57 | cli_args = [":-: description :-:"]
58 | output = '''
59 | | Description |
60 | |-------------|
61 | | Not a fizz |
62 | | Not a buzz |
63 | | Big, red. |
64 | | |'''
65 |
66 |
67 | [expect."select only description by regex"]
68 | cli_args = [":-: /Description/ :-:"]
69 | output = '''
70 | | Description |
71 | |-------------|
72 | | Not a fizz |
73 | | Not a buzz |
74 | | Big, red. |
75 | | |'''
76 |
77 |
78 | [expect."select only the big red row"]
79 | # Note: header row always survives
80 | cli_args = [":-: * :-: 'Big, red' "]
81 | output = '''
82 | | Name | Description | |
83 | |:----:|-------------|-----------------------------|
84 | | Barn | Big, red. | And this is an extra column |'''
85 |
86 |
87 | [expect."chained"]
88 | cli_args = [":-: * :-: * | :-: * :-: * | "]
89 | output = '''
90 | | Name | Description | |
91 | |:----:|-------------|-----------------------------|
92 | | Foo | Not a fizz | |
93 | | Bar | Not a buzz | |
94 | | Barn | Big, red. | And this is an extra column |
95 | | Fuzz | | |'''
96 |
97 | [expect."output plain"]
98 | cli_args = ["-o", "plain", ":-: * :-: *"]
99 | output = '''
100 | Name Description
101 | Foo Not a fizz
102 | Bar Not a buzz
103 | Barn Big, red. And this is an extra column
104 | Fuzz
105 | '''
106 |
--------------------------------------------------------------------------------
/tests/md_cases/wrapping.toml:
--------------------------------------------------------------------------------
1 | [given]
2 | # 1 2 3 4 5
3 | # 345678901234567890123456789012345678901234567890
4 | md = '''
5 | This text has both [an inline link](https://example.com/inline) and a [referenced link][1]. It also has an image:
6 |
7 | 
8 |
9 | [1]: https://example.com/referenced
10 |
11 | > We can also have text that wraps within quoted text.
12 |
13 | - Or we can have text that wraps within ordered lists
14 | - including sublists, which should take the indentation into account
15 | - and even if there are multiple items that are in there
16 | '''
17 | # 1 2 3 4 5
18 | # 345678901234567890123456789012345678901234567890
19 |
20 | [chained]
21 | needed = false
22 |
23 |
24 | [expect."wrapping at 50"]
25 | cli_args = ['--wrap-width=50', '--link-format=keep']
26 | output = '''
27 | This text has both
28 | [an inline link](https://example.com/inline) and a
29 | [referenced link][1]. It also has an image:
30 |
31 | 
32 |
33 | > We can also have text that wraps within quoted
34 | > text.
35 |
36 | - Or we can have text that wraps within ordered
37 | lists
38 |
39 | - including sublists, which should take the
40 | indentation into account
41 | - and even if there are multiple items that are
42 | in there
43 |
44 | [1]: https://example.com/referenced
45 | '''
46 |
--------------------------------------------------------------------------------