Skip to content

Commit 58cc8cf

Browse files
authored
Merge pull request #43 from javiereguiluz/code_loc
Added a property to tweak the design of code listings
2 parents 842be11 + 7a6372d commit 58cc8cf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Renderers/CodeNodeRenderer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public function render(): string
8383
'languageMapping' => self::LANGUAGES_MAPPING[$language] ?? $language,
8484
'code' => $code,
8585
'lineNumbers' => rtrim($lineNumbers),
86+
// this is the number of digits of the codeblock lines-of-code
87+
// e.g. LOC = 5, digits = 1; LOC = 18, digits = 2
88+
// this is useful to tweak the code listings according to their length
89+
'numLocDigits' => strlen((string) \count($lines)),
8690
]
8791
);
8892
}

src/Templates/default/html/code.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="literal-block">
1+
<div class="literal-block loc-{{ numLocDigits }}">
22
<div class="highlight-{{ language }}">
33
<table class="highlighttable">
44
<tr>

0 commit comments

Comments
 (0)