Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't load metadata #9

Open
droslean opened this issue Feb 23, 2023 · 1 comment
Open

[BUG] Can't load metadata #9

droslean opened this issue Feb 23, 2023 · 1 comment

Comments

@droslean
Copy link

My .md file:

---
locale: en-US
UID: whatever
type: type
---

My TEST content 
	source, err := os.ReadFile(path)
	if err != nil {
		......
	}
	markdown := goldmark.New(
		goldmark.WithExtensions(
			meta.New(
				meta.WithStoresInDocument(),
			),
		),
	)

	document := markdown.Parser().Parse(text.NewReader(source))
	metaData := document.OwnerDocument().Meta()

	fmt.Printf("%s\n", string(document.Text(source)))

	fmt.Printf("METADATA: %#v\n", metaData)

OUTPUT:

---locale: en-USUID: whatevertype: typeMy TEST content
METADATA: map[string]interface {}{}

@yuin Is there any way to debug this? Or at least throw an error to understand why the metadata can't be loaded?

@droslean
Copy link
Author

I tried to uncomment this line to debug it and here is the output

Document {
    Heading {
        RawText: "---
locale: en-US
UID: whatever
type: type"
        HasBlankPreviousLines: true
        Level: 2
        Text(SoftLineBreak): "---"
        Text(SoftLineBreak): "locale: en-US"
        Text(SoftLineBreak): "UID: whatever"
        Text: "type: type"
    }
    Paragraph {
        RawText: "My TEST content"
        HasBlankPreviousLines: true
        Text: "My TEST content"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant