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 error lines in code blocks #1314

Closed
4 tasks done
Newbie012 opened this issue Sep 9, 2022 · 2 comments · Fixed by #1534
Closed
4 tasks done

Support error lines in code blocks #1314

Newbie012 opened this issue Sep 9, 2022 · 2 comments · Fixed by #1534

Comments

@Newbie012
Copy link

Newbie012 commented Sep 9, 2022

Is your feature request related to a problem? Please describe.

I want to be able to write an error message inside my code block and make it look like it's an error.

Currently, it blends with the code:

image

Describe the solution you'd like

I'm not sure if there's a known syntax for it, but I would like the option to "highlight" a row as an error row:

```typescript{2:error}
client.query(sql`
    SELECT idd FROM comments
           ~~~ <<<< Invalid Query: column "idd" does not exist
`);

 ```.

image

Describe alternatives you've considered

Haven't found any

Additional context

No response

Validations

@brc-dd
Copy link
Member

brc-dd commented Sep 9, 2022

As a workaround, add these styles:

.error {
    --vp-code-line-highlight-color: var(--vp-c-red-dimm-2);
}

And in markdown, do something like this:

<div class="error">

```ts{3}
client.query(sql`
    SELECT idd FROM comments
           ~~~ <<<< Invalid Query: column "idd" does not exist
`);
```

</div>

This won't work if you want normal as well as error highlighting in same code block.

Output:

image

@Newbie012
Copy link
Author

That's amazing! thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants