File tree Expand file tree Collapse file tree 3 files changed +66
-12
lines changed Expand file tree Collapse file tree 3 files changed +66
-12
lines changed Original file line number Diff line number Diff line change 1
1
-- draw horizontal rules above and below code blocks to separate them nicely
2
2
3
+ code_classes =
4
+ {
5
+ [" normal" ] = {
6
+ [" font" ] = " \\ small" ,
7
+ },
8
+ [" small" ] = {
9
+ [" font" ] = " \\ scriptsize" ,
10
+ },
11
+ [" tiny" ] = {
12
+ [" font" ] = " \\ tiny" ,
13
+ },
14
+ }
15
+
3
16
function CodeBlock (block )
17
+ local class = block .classes [1 ]
18
+ local class_spec = code_classes [string.lower (class or " " )]
19
+ if not class_spec then
20
+ class_spec = code_classes [" normal" ]
21
+ end
22
+ font = class_spec [" font" ]
4
23
return {
5
- pandoc .RawInline (' latex' , [[
6
- \vskip 3pt%
24
+ pandoc .RawInline (' latex' , string.format ( [[
25
+ \vskip 3pt
7
26
\begin{customcodeblock}
8
27
\textbf{\textit{\textcolor{codeblock-header}{\small \BeginDemarcated{Code}}}}
9
- ]] ),
28
+ %s
29
+ ]] , font )),
10
30
block ,
11
31
pandoc .RawInline (' latex' , [[
12
32
\textbf{\textit{\textcolor{codeblock-header}{\small \EndDemarcated{Code}}}}
Original file line number Diff line number Diff line change @@ -428,6 +428,49 @@ The result looks like this:
428
428
int i = 42;
429
429
```
430
430
431
+ You can customize the font size, in case code runs off the edge of the page and can't be word-wrapped:
432
+
433
+ ````md
434
+ ``` {.small}
435
+ {
436
+ "Foo": {
437
+ "Bar": {
438
+ "Baz":
439
+ "/some/very/long/string/that/can't/be/word/wrapped/e.g./because/it's/encoded/in/json",
440
+ }
441
+ }
442
+ }
443
+ ```
444
+ ````
445
+
446
+ The result looks like this:
447
+
448
+ ``` {.small}
449
+ {
450
+ "Foo": {
451
+ "Bar": {
452
+ "Baz":
453
+ "/some/very/long/string/that/can't/be/word/wrapped/e.g./because/it's/encoded/in/json",
454
+ }
455
+ }
456
+ }
457
+ ```
458
+
459
+ You can use `.normal`, `.small`, or `.tiny` (illustrated below):
460
+
461
+ ``` {.tiny}
462
+ {
463
+ "Foo": {
464
+ "Bar": {
465
+ "Baz":
466
+ "/some/very/long/string/that/can't/be/word/wrapped/e.g./because/it's/encoded/in/json",
467
+ }
468
+ }
469
+ }
470
+ ```
471
+
472
+ The default case is `.normal`.
473
+
431
474
## Footnotes {#sec:footnotes}
432
475
433
476
```md
Original file line number Diff line number Diff line change 164
164
% }
165
165
% \makeatother
166
166
167
- % Make all verbatim environments use \small font.
168
- \usepackage {etoolbox }
169
- \makeatletter
170
- \patchcmd {\@verbatim }
171
- {\verbatim@font }
172
- {\verbatim@font\small }
173
- {}{}
174
- \makeatother
175
-
176
167
% Left-justify the document.
177
168
\usepackage [document ]{ragged2e }
178
169
\RaggedRight {}
You can’t perform that action at this time.
0 commit comments