# Resize code blocks?

**URL:** https://meta.discourse.org/t/resize-code-blocks/218460
**Category:** Feature
**Created:** [February 16, 2022, 8:32pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460 "2022-02-16T20:32:05Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [February 16, 2022, 8:32pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/1 "2022-02-16T20:32:05Z")

</div>

I’m looking for a feature or a theme that would allow me, as a reader, to resize code blocks in posts.

Why? We spend a lot of time looking at logs, and depending on the environment, there can be a lot of “preamble” on each log line. Here’s an example:

 ![Selection_1144](https://global.discourse-cdn.com/meta/original/3X/a/a/aab9b0bfd82f463fffd0f6e3bd8fb47086b64ae0.jpeg)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 16, 2022, 9:07pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/2 "2022-02-16T21:07:36Z")

</div>

Maybe we can re-use our “Expand Table” feature to work on codeblocks too…

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [July 19, 2022, 4:55pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/5 "2022-07-19T16:55:51Z")

</div>

Well, I haven’t figured out horizontal resize, but I was able to add vertical resize with some CSS:

```plaintext
// Scrollable code blocks
.hljs {
    resize: vertical;
    height: 515px;
    max-height: unset;
}

```

Edit: Well… nevermind. I just realized that when the code block is short, that^ makes the div too tall. :frowning:

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [July 19, 2022, 9:11pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/6 "2022-07-19T21:11:52Z")

</div>

It’s probably a naïve suggestion, but what about a `white-space: break-spaces;` to have word wrap?

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [July 20, 2022, 3:31am UTC](https://meta.discourse.org/t/resize-code-blocks/218460/7 "2022-07-20T03:31:50Z")

</div>

I actually did some [work earlier in the year](https://github.com/discourse/discourse/commit/ff96d541e955edb094aa4dc639978bf7ad2f0fc3) to fullscreen code blocks. First, you have to have the `show_copy_button_on_codeblocks` setting enabled. Then, any code block that has a horizontal scroll will have 2 buttons – the copy button and the fullscreen button (the copy button will be there regardless):

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/b/6/8b605eabe010211d29ed21016b7bb03fd6279fa9.png)

Then a modal will be shown without the horizontal scrolling:

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/1/7/f17c21af1793ac4157bd3e6398ea0fd6b26a832c.png)

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [July 20, 2022, 11:30am UTC](https://meta.discourse.org/t/resize-code-blocks/218460/8 "2022-07-20T11:30:31Z")

</div>

@Canapin you really don’t want code blocks to wrap. That’s actually why I format 99% of the posts that I touch: to put the things that shouldn’t linewrap in code blocks.

And thanks for the tip @martin. I may try this in the meantime, but I’m still holding out hope for inline resize… :crossed_fingers: :innocent:

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [July 20, 2022, 2:10pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/9 "2022-07-20T14:10:08Z")

</div>

I’ve turned on `show_copy_button_on_codeblocks` and this is a nice interim step. :innocent:  
Worth noting that you have to actually mouseover the code block for the buttons to show up. I thought at first it wasn’t working.

And on the topic of inline resizable code blocks, it might be worth pointing out that the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) SQL editor is fully resizable. (I know the page is built differently, but…)

---

<div class="post-metadata">

### Author: ![Jose\_C\_Gomez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jose_c_gomez/32/137297_2.png) [@Jose\_C\_Gomez](https://meta.discourse.org/u/Jose_C_Gomez)
#### Post date: [November 22, 2022, 10:01pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/10 "2022-11-22T22:01:38Z")

</div>

So when I enable show\_copy\_button\_on\_codeblocks it doesn’t show the copy option (or the expand). Is there something else I’m missing?

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [November 22, 2022, 11:45pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/11 "2022-11-22T23:45:27Z")

</div>

The expand button will only show if the code block scrolls horizontally. I am not sure why the copy button wouldn’t show. It is hidden until you hover the code block, maybe that’s it?

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 24, 2023, 5:57pm UTC](https://meta.discourse.org/t/resize-code-blocks/218460/12 "2023-03-24T17:57:08Z")

</div>

I’ve been quite for a while, but I still want to be able to expand code blocks inline.

Right at the moment, I’m viewing code in the popup. And the reply/quote feature apparently isn’t available. :sadpanda:
