mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-02 21:32:34 +00:00
feat: add support for --content-appearance
This commit is contained in:
committed by
Manuel Rüger
parent
d2717f031d
commit
9516939c7d
@@ -51,7 +51,7 @@ var (
|
||||
reHeaderPatternMacro = regexp.MustCompile(`<!-- Macro: .*`)
|
||||
)
|
||||
|
||||
func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFilename bool, filename string, parents []string, titleAppendGeneratedHash bool) (*Meta, []byte, error) {
|
||||
func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFilename bool, filename string, parents []string, titleAppendGeneratedHash bool, defaultContentAppearance string) (*Meta, []byte, error) {
|
||||
var (
|
||||
meta *Meta
|
||||
offset int
|
||||
@@ -81,7 +81,6 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFi
|
||||
if meta == nil {
|
||||
meta = &Meta{}
|
||||
meta.Type = "page" // Default if not specified
|
||||
meta.ContentAppearance = FullWidthContentAppearance // Default to full-width for backwards compatibility
|
||||
}
|
||||
|
||||
header := cases.Title(language.English).String(matches[1])
|
||||
@@ -152,10 +151,6 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFi
|
||||
meta.Type = "page"
|
||||
}
|
||||
|
||||
if meta.ContentAppearance == "" {
|
||||
meta.ContentAppearance = FullWidthContentAppearance // Default to full-width for backwards compatibility
|
||||
}
|
||||
|
||||
if titleFromH1 && meta.Title == "" {
|
||||
meta.Title = ExtractDocumentLeadingH1(data)
|
||||
}
|
||||
@@ -167,6 +162,17 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, titleFromFi
|
||||
}
|
||||
}
|
||||
|
||||
// Use the global content appearance flag if the header is not set in the document
|
||||
if meta != nil && defaultContentAppearance != "" && meta.ContentAppearance == "" {
|
||||
if strings.TrimSpace(defaultContentAppearance) == FixedContentAppearance {
|
||||
meta.ContentAppearance = FixedContentAppearance
|
||||
} else {
|
||||
meta.ContentAppearance = FullWidthContentAppearance
|
||||
}
|
||||
} else if meta != nil && meta.ContentAppearance == "" {
|
||||
meta.ContentAppearance = FullWidthContentAppearance // Default to full-width if nothing else is set for backwards compatibility
|
||||
}
|
||||
|
||||
if meta == nil {
|
||||
return nil, data, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user