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

Convert all code listings to use new <Listing> preprocessor #3919

Open
1 of 20 tasks
chriskrycho opened this issue May 14, 2024 · 4 comments
Open
1 of 20 tasks

Convert all code listings to use new <Listing> preprocessor #3919

chriskrycho opened this issue May 14, 2024 · 4 comments

Comments

@chriskrycho
Copy link
Contributor

chriskrycho commented May 14, 2024

As of #3918, we have a preprocessor that allows us to author with a custom HTML tag, Listing, roughly as if it were a component in a templating language. This input:

<Listing number="1-1" file-name="src/lib.rs" caption="A listing showing how to use a `Listing`">

```rust
fn main() {
    println!("Hello, listing!");
}
```

</Listing>

…will generate this output in the regular book (and strip all the tags in the NoStarch book):

<figure class="listing">
<span class="file-name">Filename: src/lib.rs</span>
<pre><pre class="playground"><code class="language-rust">fn main() {
    println!("Hello, listing!");
}</code></pre></pre>
<figcaption>Listing 1-2: A listing showing how to use a <code>Listing</code></figcaption>
</figure>

As described in the PR adding support for this, the result is more accessible HTML, which will also give us a nice way to hook in for styling things better if we so choose.


If you’d like to help, please leave a comment below noting which chapter you’d like to pick up so folks don’t do duplicate work! If it already has a user handle by it, please don’t work on that chapter.

Note for contributors: when converting to a <Listing>, you can drop the leading Listing <number>: from the caption arg, since it handles that automatically with the number arg.

@davidkurilla
Copy link
Contributor

davidkurilla commented May 16, 2024

I'd like to help with chapter 1.

@davidkurilla
Copy link
Contributor

Thanks for the feedback for my pervious contribution! I plan to work on converting chapters 2 and 3

@chriskrycho
Copy link
Contributor Author

Very good! Thank you! 💙

@SpectralPixel
Copy link

I'll do chapters 6-10. Already working on it.

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

No branches or pull requests

3 participants