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

Add codeblock language as title remark plugin #4418

Merged

Conversation

hichemfantar
Copy link
Contributor

@hichemfantar hichemfantar commented Jan 3, 2025

Introduce a new remark plugin that sets the title metadata for code blocks based on their language, along with updates to dependencies and README documentation for clarity and consistency.

A custom remark plugin that automatically sets the title metadata for code blocks in Markdown files based on the block's language.

Features

  • Adds title Metadata: For code blocks with a specified language (e.g., js, python), the plugin sets the title metadata to match the language.
  • Preserves Existing Metadata: If the code block already contains metadata (meta) but lacks a title, the plugin appends the title without removing the existing metadata.
  • Ignores Code Blocks with Existing title: If the meta field already includes a title property, the plugin does nothing to avoid overwriting it.

read more at facebook/docusaurus#10808

before
image

after
image

before
image

after
image

Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit a76df88
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/67786e018947fe0008004c10
😎 Deploy Preview https://deploy-preview-4418--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hichemfantar hichemfantar marked this pull request as ready for review January 3, 2025 23:15
@hichemfantar hichemfantar changed the title Add codeblock language as title plugin Add codeblock language as title remark plugin Jan 3, 2025
@Abbondanzo Abbondanzo merged commit a1babcf into facebook:main Jan 4, 2025
4 checks passed
@hichemfantar hichemfantar deleted the remark-codeblock-language-as-title branch January 4, 2025 09:36
@Simek
Copy link
Collaborator

Simek commented Jan 4, 2025

@hichemfantar I think that it's a nice feature, but we should not add language as a code block title by default, the title should be fully controlled by author, and only added when specified.

This approach usually create a noise, and does not add that much information/context for the users, also stretching the page in length. You can see that we don't use that pattern on react.dev nor docs.expo.dev.

@hichemfantar
Copy link
Contributor Author

hichemfantar commented Jan 4, 2025

I personally find this very helpful but I could make it more presentable by mapping the language to a different display name as shown here facebook/docusaurus#10808 (comment)

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

Successfully merging this pull request may close these issues.

4 participants