Skip to content

Move code block titles into comments (i18nIgnore)#3635

Merged
hippotastic merged 4 commits into
withastro:mainfrom
hippotastic:hippotastic/prepare-expressive-code-migration
Jun 30, 2023
Merged

Move code block titles into comments (i18nIgnore)#3635
hippotastic merged 4 commits into
withastro:mainfrom
hippotastic:hippotastic/prepare-expressive-code-migration

Conversation

@hippotastic
Copy link
Copy Markdown
Contributor

What kind of changes does this PR include?

  • Changes to the docs site code

Description

  • To prepare the upgrade from our old built-in code snippets component to the new Expressive Code package, we have to make some changes to our MDX contents.
  • Our old code snippets supported defining code block titles by adding a bold formatted paragraph directly above the fenced code block. This syntax is no longer supported in Expressive Code because it may be unexpected that surrounding markdown code influences the rendering of a code block.
  • This PR therefore replaces any occurrences of this pattern with file name comments inside the code blocks.
  • It also uses the proper comment syntax based on the respective file type and contents:
    • astro: If a frontmatter block is present, a // JS comment is added at the beginning of the frontmatter block. Otherwise, an <!-- HTML comment --> is added at the beginning of the code.
    • markdown/md: If a frontmatter block is present, a # YAML/TOML comment is added at the beginning of the frontmatter block. Otherwise, an <!-- HTML comment --> is added at the beginning of the code.
    • js(x)/ts(x): A // Single-line comment is added at the beginning of the code.
    • xml: A title="..." attribute is added to the opening code fence as no title comments are supported inside xml snippets yet.
  • Note: This PR includes changes to generated files in src/content/en/guides/integrations-guide. These changes will also be submitted to the source package README files to prevent them from being overwritten later.

@github-actions github-actions Bot added the i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! label Jun 30, 2023
@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 30, 2023

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 44b99c0
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/649eeecaba0a740009123fea
😎 Deploy Preview https://deploy-preview-3635--astro-docs-2.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.

Copy link
Copy Markdown
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspected every English page by hand, and can confirm no wonkiness to any code snippets! 🥳

(I did notice that some snippets that never did have titles maybe should... but that's a story for another day!)

Great work, Hippo! Thanks for being so thorough, and for also tackling these integrations READMES at the source!

@hippotastic hippotastic merged commit 61b5526 into withastro:main Jun 30, 2023
@hippotastic hippotastic deleted the hippotastic/prepare-expressive-code-migration branch June 30, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants