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

Implement title field for first H1/H2 heading (if no title field exists) #2290

Open
mdbraber opened this issue Apr 2, 2024 · 6 comments
Open
Labels
feature-request New feature or request.

Comments

@mdbraber
Copy link

mdbraber commented Apr 2, 2024

I'd like to be able to query the title of a Markdown document being the first H1 or H2 heading in the document. This is described in the comments of the Markdown parser:

public title?: string;
- but is not (yet?) implemented. Would it be possible to implement this?

Related FR: #29

@mdbraber mdbraber added the feature-request New feature or request. label Apr 2, 2024
@mdbraber
Copy link
Author

mdbraber commented Apr 2, 2024

For those who want a quick solution, update data-import/markdown-file.ts around line 67 and include

let title: string | undefined;
if (metadata.headings && metadata.headings.length > 0) {
    title = metadata.headings[0].heading;
}

and include title in the returned PageMetadata

@SpocWeb
Copy link

SpocWeb commented May 6, 2024

@mdbraber do you want to make your change into a Pull-Request?

I would propose to even add the full HeadingCache[] to the Page-Info,
so we can query it for any number of problems.

@SpocWeb
Copy link

SpocWeb commented May 6, 2024

I think it is more value to provide the full Heading Info as demonstrated here:
master...SpocWeb:obsidian-dataview:headings-in-PageInfo

@mdbraber
Copy link
Author

Don't have time to do it right now; but I'll see if I can get to it later

@SpocWeb
Copy link

SpocWeb commented May 14, 2024

Try to have a look at my link above, because it covers all Headings. If you would second this, I would make it a PR.

@mdbraber
Copy link
Author

Fine with me!

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

No branches or pull requests

2 participants