-
-
Notifications
You must be signed in to change notification settings - Fork 145
Automatically Extract Title from First Heading in Markdown #655
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
Automatically Extract Title from First Heading in Markdown #655
Conversation
Thanks for your working 😄 Could you add the test code for that? For running code check with CI, please fetch and merge upstream branch |
For sure, working on it! |
CI test has been failed due to the check of code styling by Prettier. In most cases, it could fix just by running ref. https://github.com/marp-team/.github/blob/master/CONTRIBUTING.md#requirements-in-pull-request |
I see, I had conflicts with my local rules. Thanks for the heads up! |
headingContentToken.type === 'inline' && | ||
(!bestHeading || level < bestHeading.level) | ||
) { | ||
bestHeading = { level, content: headingContentToken.content.trim() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the initial release is fine with this. In future releases, it would be better to use MarkdownIt.renderInline()
to reflect the exact contents.
// Helper to create mock heading tokens | ||
const createHeadingTokens = (tag: string, content: string) => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to test with the result of parse by actual Marp or markdown-it instance.
You're right, haven't though that would be something desired. Co-authored-by: Yuki Hattori <[email protected]>
No worries, I'll like to see this feature so whatever is needed to merge the pr 😄 |
📋 Automatically Extract Title from First Heading in Markdown
📝 Description
This pull request introduces functionality to automatically extract the title from the first heading in the Markdown document, prioritizing the highest hierarchy (
h1 > h2 > h3
, etc.), when no title is provided via global directives (marpCLITitle
). It ensures that the title is always set appropriately, improving the user experience for slide generation.🔄 Changes
extractTitleFromFirstHeading
function toinfo-plugin.ts
:h1
is found for performance.infoPlugin
to use the extracted title as a fallback when no global directive title is provided.🎯 Purpose
The primary purpose of this pull request is to enhance the title extraction logic for Marp CLI. It ensures that users who do not explicitly provide a title via global directives still have a meaningful title extracted from their Markdown content, improving the overall usability of the tool.
💬 Additional Comments
Let me know if further adjustments are needed! 🚀
Related Issues
Fixes #131