parent
476639ee9b
commit
3d7e79031f
|
@ -22,6 +22,7 @@ An entire file:
|
||||||
|
|
||||||
<!-- emdbed: emdbed_example_test.go -->
|
<!-- emdbed: emdbed_example_test.go -->
|
||||||
```go
|
```go
|
||||||
|
// Package emdbed is for embedding "things" in your markdown
|
||||||
package emdbed
|
package emdbed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -56,15 +57,15 @@ func Example() {
|
||||||
|
|
||||||
Just the package:
|
Just the package:
|
||||||
|
|
||||||
<!-- emdbed: emdbed_example_test.go L1 L1 -->
|
<!-- emdbed: emdbed_example_test.go L2 L2 -->
|
||||||
```go
|
```go
|
||||||
package emdbed
|
package emdbed
|
||||||
```
|
```
|
||||||
<!-- /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
|
```go
|
||||||
package emdbed
|
package emdbed
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package emdbed is for embedding "things" in your markdown
|
||||||
package emdbed
|
package emdbed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
10
io.go
10
io.go
|
@ -25,7 +25,15 @@ func (e emdbed) line(line int, end bool) (int, error) {
|
||||||
if len(indexes) < line {
|
if len(indexes) < line {
|
||||||
return 0, fmt.Errorf("file %q has no line %d", e.name, 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) {
|
func (e emdbed) regex(pattern string, end bool) (int, error) {
|
||||||
|
|
Loading…
Reference in New Issue