Browse Source

Fix line embedding

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main v0.0.2
jolheiser 4 weeks ago
parent
commit
3d7e79031f
Signed by: jolheiser GPG Key ID: B853ADA5DA7BBF7A
  1. 7
      README.md
  2. 1
      emdbed_example_test.go
  3. 10
      io.go

7
README.md

@ -22,6 +22,7 @@ An entire file:
<!-- emdbed: emdbed_example_test.go -->
```go
// Package emdbed is for embedding "things" in your markdown
package emdbed
import (
@ -56,15 +57,15 @@ func Example() {
Just the package:
<!-- emdbed: emdbed_example_test.go L1 L1 -->
<!-- emdbed: emdbed_example_test.go L2 L2 -->
```go
package emdbed
```
<!-- /emdbed -->
First line until the end of imports:
Package line until the end of imports:
<!-- emdbed: emdbed_example_test.go L1 /\)/ -->
<!-- emdbed: emdbed_example_test.go L2 /\)/ -->
```go
package emdbed

1
emdbed_example_test.go

@ -1,3 +1,4 @@
// Package emdbed is for embedding "things" in your markdown
package emdbed
import (

10
io.go

@ -25,7 +25,15 @@ func (e emdbed) line(line int, end bool) (int, error) {
if len(indexes) < line {
return 0, fmt.Errorf("file %q has no line %d", e.name, line)
}
return indexes[line-1][0], nil
dec := 1
if !end {
dec++
}
var inc int
if !end {
inc++
}
return indexes[line-dec][0] + inc, nil
}
func (e emdbed) regex(pattern string, end bool) (int, error) {

Loading…
Cancel
Save