Skip to content

Commit 9258de6

Browse files
authored
feat: allow overriding max_lines parameter via data-max-lines attribute (#33)
For example, ````markdown ```sh {data-max-lines=20} tree /path/to/large-folder ... ... ``` ```` fix: correct the max_lines calculation
1 parent 912077f commit 9258de6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

assets/mods/code-block-panel/js/panel.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ export default class Panel {
4848

4949
private maxLines() {
5050
const lines = this.lines()
51-
if (params.max_lines > 0 && lines.length > params.max_lines) {
52-
const offsetTop = lines[params.max_lines - 1].offsetTop
51+
const maxLines = this.code.closest('.highlight')?.getAttribute('data-max-lines') ?? params.max_lines
52+
if (maxLines > 0 && lines.length > maxLines) {
53+
const offsetTop = lines[maxLines].offsetTop
5354
if (offsetTop > 0) {
5455
this.pre.style.maxHeight = this.maxHeight = offsetTop + 'px'
5556
}

0 commit comments

Comments
 (0)