Skip to content

Conversation

@Jengamon
Copy link
Contributor

This should resolve #343 by adding a shortcode that goes around code blocks that should be marked incorrect (incorrect_code_block()), highlights them in a dark red, and makes the left border red. Looks like this:
Screen Shot 2022-04-16 at 4 50 25 PM

from:

Just keep in mind that `&World` will conflict with _any_ mutable Query:

{% incorrect_code_block() %}
```rust
fn invalid_system(world: &World, transforms: Query<&mut Transform>) {
}
```
{% end %}

In these cases, consider using our new [ParamSets](/news/bevy-0-7/#paramsets) to resolve the conflict:

```rust
fn valid_system(set: ParamSet<(&World, Query<&mut Transform>)>) {
}
```

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Book labels Apr 16, 2022
@Jengamon
Copy link
Contributor Author

Jengamon commented Apr 16, 2022

I would have loved to do something like

```rust,{.incorrect}
[CONTENT GOES HERE]
```

or something to that effect, but that breaks syntax highlighting. This was the best option that I found to get this feature working. It works by having a shortcode just add a <div class="incorrect"> around the body that it's given, then I added some Sass in _html.scss to get all the colors working given a div.incorrect.

Maybe someone can fancy it up by adding Bevy icons or summat to the div like the Rust docs, but this is just an MVP (and my first PR here).

Copy link
Contributor

@doup doup left a comment

Choose a reason for hiding this comment

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

The solution looks good. 👍

The only thing, I think the styles should go in another file. Check the comment.

Comment on lines 15 to 25
div.incorrect {
background-color: #542326;
border-left: 10px solid red;
border-radius: 10px;

.z-code,
.z-code code {
background-color: #542326;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think is better to put this snippet in components/_syntax-theme.scss which is where all the syntax highlighting styles are. This file (html.scss) should be only for html element tweaks (although it also touches body right now, this is fixed in #315).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I've moved it~

@doup
Copy link
Contributor

doup commented Apr 16, 2022

Btw, maybe an issue can be opened in Zola to allow adding extra classes into code blocks? They already have some annotations, maybe it's not difficult for them to add this option.

See: https://www.getzola.org/documentation/content/syntax-highlighting/#annotations

@doup
Copy link
Contributor

doup commented Apr 17, 2022

Hi! Now that I see it again, I think the PR should contain only the actual changes, not the code formatting changes. But, that's my opinion, I don't know what's the Bevy policy here.

cc @alice-i-cecile

@Jengamon
Copy link
Contributor Author

Ok, I've undone all the formatting for _html.scss, but _syntax-theme.scss didn't have a consistent space formatting (the properties are sometimes 1 space, sometimes 4.) I could undo the selector formatting.

Copy link
Contributor

@doup doup left a comment

Choose a reason for hiding this comment

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

OK, makes sense for syntax-theme file. 👌

@alice-i-cecile
Copy link
Member

Yeah, we should try to fix and enforce formatting issues in a seperate PR if possible.

@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Apr 17, 2022
This should resolve #343 by adding a shortcode that goes around code blocks that should be marked incorrect (`incorrect_code_block()`), highlights them in a dark red, and makes the left border red. Looks like this:
<img width="1213" alt="Screen Shot 2022-04-16 at 4 50 25 PM" src="https://user-images.githubusercontent.com/1479994/163690976-77abfe98-fd71-4988-afcb-02e3be35491a.png">

from:

~~~markdown
Just keep in mind that `&World` will conflict with _any_ mutable Query:

{% incorrect_code_block() %}
```rust
fn invalid_system(world: &World, transforms: Query<&mut Transform>) {
}
```
{% end %}

In these cases, consider using our new [ParamSets](/news/bevy-0-7/#paramsets) to resolve the conflict:

```rust
fn valid_system(set: ParamSet<(&World, Query<&mut Transform>)>) {
}
```
~~~
@bors
Copy link

bors bot commented Apr 17, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title Add incorrect code block support [Merged by Bors] - Add incorrect code block support Apr 17, 2022
@bors bors bot closed this Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Book C-Feature A new feature, making something new possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mark code that shouldn't compile or fails in runtime

3 participants