emdbed/README.md

1.6 KiB

emdbed

Embed "things" in your markdown files.

Given the same input, emdbed should give idempotent results.

Examples

The following are generated using readme.go and go generate ./....

An entire file:

package emdbed

import (
	"fmt"
)

func Example() {
	fi, err := testdata.Open("testdata/main.md")
	defer fi.Close()
	out, err := Convert("testdata", fi)
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
	// Output:
	//<!-- emdbed: main.go -->
	//```go
	//package main
	//
	//import "fmt"
	//
	//func main() {
	//	fmt.Println("Hello, world!")
	//}
	// ```
	//<!-- /emdbed -->
}

Just the package:

package emdbed

First line until the end of imports:

package emdbed

import (
	"fmt"
)

Only the example func

func Example() {
	fi, err := testdata.Open("testdata/main.md")
	defer fi.Close()
	out, err := Convert("testdata", fi)
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
	// Output:
	//<!-- emdbed: main.go -->
	//```go
	//package main
	//
	//import "fmt"
	//
	//func main() {
	//	fmt.Println("Hello, world!")
	//}
	// ```
	//<!-- /emdbed -->
}

A file in another directory (choosing/overriding the language)

package main

import "fmt"

func main() {
	fmt.Println("This file has no extension")
}

License

MIT