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

Support Some Expressive Code Features #714

Open
khalidabuhakmeh opened this issue Dec 13, 2024 · 0 comments
Open

Support Some Expressive Code Features #714

khalidabuhakmeh opened this issue Dec 13, 2024 · 0 comments

Comments

@khalidabuhakmeh
Copy link
Contributor

Expressive code features allow developers to add more metadata to a code block to illustrate the intent of the code block better. For example, you can highlight several lines, highlight symbols via regular expressions, mark text as inserted or deleted, and even perform a diff.

Describe the solution

Allow developers to add additional metadata next to the snippet name that will get added to the code block at render time.

// begin-snippet: App:HelloWorld
// Program.cs
Console.WriteLine("Hello, Again!");
Console.WriteLine("Hello, Again!");
Console.WriteLine("Hello, Again!");
// end-snippet

would become in your C# code

// begin-snippet: App:HelloWorld | {2-2} "Hello" title="Hello 3x"
// Program.cs
Console.WriteLine("Hello, Again!");
Console.WriteLine("Hello, Again!");
Console.WriteLine("Hello, Again!");
// end-snippet

And in markdown would become

<!-- snippet: App:HelloWorld -->
<a id='snippet-App:HelloWorld'></a>
```cs {2-2} "Hello" title="Hello 3x"
// Program.cs
Console.WriteLine("Hello, Again!");
Console.WriteLine("Hello, Again!");
Console.WriteLine("Hello, Again!");
```
<sup><a href='#snippet-App:HelloWorld' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The resulting output might look something like

image001767-2024-12-13 -14-36-06

Additional context

See Expressive Code at this link. https://starlight.astro.build/guides/authoring-content/#expressive-code-features and here https://github.com/expressive-code/expressive-code/tree/main/packages/astro-expressive-code

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