code-hike / codehike

Build rich content websites with Markdown and React
https://codehike.org
MIT License
4.74k stars 146 forks source link

Provide a means to auto-determine the height of CH.Code blocks with focus #258

Closed zentol closed 2 years ago

zentol commented 2 years ago

When embedding a file the only way to only show a part of the file is to use focus and manually specific a height.

While this works perfectly fine, it is quite brittle as changes to the focused area requires re-adjustments of the height, and it's also a bit tedious.

It would be nice if there'd be a way for CH to auto-determine the height to show everything in focus, or a sort-of heightPerLine setting that could be set in the configuration.

pomber commented 2 years ago

Yes, that's something I want to add.

What do you thing about a linesOfHeight option?

```js foo.js linesOfHeight=12
// from ./a-long-file.js

It could also work for focused lines:

````md
```js foo.js linesOfHeight=focus
// from ./a-long-file.js
zentol commented 2 years ago

Do I understand things correctly that linesOfHeight=12 displays exactly 12 lines, and linesOfHeight=focus displays all lines between the first&last focused line? If so, then that sounds great.

github-actions[bot] commented 2 years ago

:rocket: Issue was released in v0.7.3 :rocket: