Skip to content

Commit 0d22b86

Browse files
committed
fix typos, error args and target substitution
1 parent 2364fd6 commit 0d22b86

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ bin/mdref: ${SOURCES}
2727
.PHONY: test
2828
test: bin/mdref
2929
bin/mdref --list --headings src .
30-
diff -ur doc test/doc
31-
diff README.md test/README.md
30+
diff -ur test/doc doc
31+
diff test/README.md README.md
3232

33+
.PHONY: gentest
34+
gentest: bin/mdref
35+
bin/mdref --list --headings src test

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.0
1+
0.4.1

cmds.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (i *filter) Filter(data []byte) ([]byte, error) {
6666
var result []byte
6767
for _, m := range matches {
6868
if len(m) != 2 {
69-
return nil, fmt.Errorf("regular expressin must contain one matching group")
69+
return nil, fmt.Errorf("regular expression must contain one matching group")
7070
}
7171
result = append(result, m[1]...)
7272
result = append(result, []byte(sep)...)
@@ -82,7 +82,7 @@ func (i *Include) GetSubstitution(p string) ([]byte, error) {
8282

8383
data, err = i.extractor.extract(data)
8484
if err != nil {
85-
return nil, fmt.Errorf("include file %q; %w", err)
85+
return nil, fmt.Errorf("include file %q: %w", i.file, err)
8686
}
8787
return i.filter.Filter(data)
8888
}
@@ -167,7 +167,7 @@ func (i *NumExtractor) extract(data []byte) ([]byte, error) {
167167
end = i.end
168168
}
169169
if end > len(lines) {
170-
return nil, fmt.Errorf("end line %d after end of file (%d lines", end, len(lines))
170+
return nil, fmt.Errorf("end line %d after end of file (%d lines)", end, len(lines))
171171
}
172172
return []byte(strings.Join(lines[start:end], "\n")), nil
173173
}

doc/chapters/commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ All commands use the same basic annotation syntax:
99

1010
The following commands are supported:
1111

12+
- [`include`](#include) include content of other file
13+
- [`execute`](#execute) unclude output of command execution
14+
1215
### Include
1316

1417
The include command uses the following syntax

generate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ func generate(files []*File, resolution Resolution, source, target string) error
5959
}
6060

6161
for k := range f.refs {
62-
exp := regexp.MustCompile("({{" + k + "}})")
62+
exp := regexp.MustCompile(`\({{` + k + `}}\)`)
6363

6464
ref, _ := resolution.Resolve(k, f.relpath)
65-
data = exp.ReplaceAll(data, []byte(ref))
65+
data = exp.ReplaceAll(data, []byte("("+ref+")"))
6666
}
6767

6868
for k, r := range f.targets {

src/doc/chapters/commands.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ All commands use the same basic annotation syntax:
1010

1111
The following commands are supported:
1212

13+
- [`include`]({{cmd-include}}) include content of other file
14+
- [`execute`]({{cmd-execute}}) unclude output of command execution
15+
16+
{{cmd-include}}
1317
### Include
1418

1519
The include command uses the following syntax
@@ -73,6 +77,7 @@ using
7377
{{include}{../../../cmds.go}{filter}{(?m)^.*// ?(.*)$}}
7478
</pre>
7579

80+
{{cmd-execute}}
7681
### Execute
7782

7883
The execute command uses the following syntax

test/doc/chapters/commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ All commands use the same basic annotation syntax:
99

1010
The following commands are supported:
1111

12+
- [`include`](#include) include content of other file
13+
- [`execute`](#execute) unclude output of command execution
14+
1215
### Include
1316

1417
The include command uses the following syntax

0 commit comments

Comments
 (0)