mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
Expand the path for a specified style file
This commit is contained in:
parent
753a7c6993
commit
d9242c9a72
3 changed files with 32 additions and 4 deletions
|
|
@ -1,6 +1,11 @@
|
|||
package utils
|
||||
|
||||
import "regexp"
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
func RemoveFrontmatter(content []byte) []byte {
|
||||
if frontmatterBoundaries := detectFrontmatter(content); frontmatterBoundaries[0] == 0 {
|
||||
|
|
@ -17,3 +22,12 @@ func detectFrontmatter(c []byte) []int {
|
|||
}
|
||||
return []int{-1, -1}
|
||||
}
|
||||
|
||||
// Expands tilde and all environment variables from the given path.
|
||||
func ExpandPath(path string) string {
|
||||
s, err := homedir.Expand(path)
|
||||
if err == nil {
|
||||
return os.ExpandEnv(s)
|
||||
}
|
||||
return os.ExpandEnv(path)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue