diff --git a/org/document.go b/org/document.go index 6fa8530..a8f6201 100644 --- a/org/document.go +++ b/org/document.go @@ -23,10 +23,11 @@ import ( ) type Configuration struct { - MaxEmphasisNewLines int // Maximum number of newlines inside an emphasis. See org-emphasis-regexp-components newline. - AutoLink bool // Try to convert text passages that look like hyperlinks into hyperlinks. - DefaultSettings map[string]string // Default values for settings that are overriden by setting the same key in BufferSettings. - Log *log.Logger // Log is used to print warnings during parsing. + MaxEmphasisNewLines int // Maximum number of newlines inside an emphasis. See org-emphasis-regexp-components newline. + AutoLink bool // Try to convert text passages that look like hyperlinks into hyperlinks. + DefaultSettings map[string]string // Default values for settings that are overriden by setting the same key in BufferSettings. + Log *log.Logger // Log is used to print warnings during parsing. + ReadFile func(filename string) ([]byte, error) // ReadFile is used to read e.g. #+INCLUDE files. } // Document contains the parsing results and a pointer to the Configuration. @@ -82,7 +83,8 @@ func New() *Configuration { "EXCLUDE_TAGS": "noexport", "OPTIONS": "toc:t <:t e:t f:t pri:t todo:t tags:t", }, - Log: log.New(os.Stderr, "go-org: ", 0), + Log: log.New(os.Stderr, "go-org: ", 0), + ReadFile: ioutil.ReadFile, } } diff --git a/org/keyword.go b/org/keyword.go index 8752680..785b04a 100644 --- a/org/keyword.go +++ b/org/keyword.go @@ -127,7 +127,7 @@ func (d *Document) newInclude(k Keyword) (int, Node) { path = filepath.Join(filepath.Dir(d.Path), path) } resolve = func() Node { - bs, err := ioutil.ReadFile(path) + bs, err := d.ReadFile(path) if err != nil { d.Log.Printf("Bad include %#v: %s", k, err) return k