Allow non-latin characters in paths

This makes gmnhg use [\pL\d\-_] to match paths instead of \w,
allowing letter characters from any Unicode language in file
paths.

Fixes #48.
This commit is contained in:
mntn 2021-12-25 11:51:26 -05:00 committed by GitHub
parent ee8e58ffb9
commit f858ec383b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -149,9 +149,9 @@ const (
)
var (
tmplNameRegex = regexp.MustCompile("^" + templateBase + `([\w-_ /]+)\.gotmpl$`)
leafIndexRegex = regexp.MustCompile("^" + contentBase + `([\w-_ /]+)/index\.[\w]+$`)
pagePathRegex = regexp.MustCompile("^" + contentBase + `([\w-_ /]+)/([\w-_ ]+)\.md$`)
tmplNameRegex = regexp.MustCompile("^" + templateBase + `([\pL\d\-_ /]+)\.gotmpl$`)
leafIndexRegex = regexp.MustCompile("^" + contentBase + `([\pL\d\-_ /]+)/index\.[\pL\d_]+$`)
pagePathRegex = regexp.MustCompile("^" + contentBase + `([\pL\d\-_ /]+)/([\pL\d\-_ ]+)\.md$`)
)
var hugoConfigFiles = []string{"config.toml", "config.yaml", "config.json"}

View file

@ -62,7 +62,7 @@ var (
yamlDelimiter = []byte("---\n")
tomlDelimiter = []byte("+++\n")
jsonObjectRegex = regexp.MustCompile(`\A(\{[\s\S]*\})\n\n`)
orgModeRegex = regexp.MustCompile(`\A((?:#\+\w+\[?\]?: ?[^\n\r]*\n)+)`)
orgModeRegex = regexp.MustCompile(`\A((?:#\+[\pL\d_]+\[?\]?: ?[^\n\r]*\n)+)`)
)
// ParseMetadata extracts TOML/JSON/YAML/org-mode format front matter