Add support for code appendices: enable code blocks with language labels, line-number gutter, and directive-based integration.
This commit is contained in:
+15
-4
@@ -38,10 +38,8 @@ const (
|
||||
dinSpaceAfterHeading = dinLineHtBody // ≈ 6.35 mm
|
||||
dinSpaceAfterParagraph = 4.0 // between body paragraphs
|
||||
|
||||
// List items use tighter line spacing than body text (1.2× instead of 1.5×).
|
||||
// This keeps lists compact while remaining legible at 12 pt.
|
||||
dinLineHtList = 5.0 // 12 pt × 1.2 ≈ 5.08 mm, rounded to 5.0
|
||||
dinSpaceAfterList = 3.0 // gap inserted after the outermost list exits
|
||||
dinLineHtList = dinLineHtBody // 1.5× IHK standard, same as body text
|
||||
dinSpaceAfterList = 3.0 // gap inserted after the outermost list exits
|
||||
)
|
||||
|
||||
// AppendixKind distinguishes between image and table annexes.
|
||||
@@ -50,6 +48,7 @@ type AppendixKind int
|
||||
const (
|
||||
AppendixKindImage AppendixKind = iota
|
||||
AppendixKindTable
|
||||
AppendixKindCode
|
||||
)
|
||||
|
||||
// Appendix holds the content for one annex entry.
|
||||
@@ -59,6 +58,8 @@ type Appendix struct {
|
||||
Title string
|
||||
Path string // image path (Kind == AppendixKindImage)
|
||||
TableData [][]string // table rows (Kind == AppendixKindTable)
|
||||
Lang string // language label (Kind == AppendixKindCode)
|
||||
Code string // source code (Kind == AppendixKindCode)
|
||||
}
|
||||
|
||||
// IHKRenderer is the central PDF generator for IHK Chemnitz project documentation.
|
||||
@@ -183,6 +184,16 @@ func (r *IHKRenderer) AddTableAppendix(title string, data [][]string) {
|
||||
})
|
||||
}
|
||||
|
||||
// AddCodeAppendix registers a source-code annex rendered with line-number gutter.
|
||||
func (r *IHKRenderer) AddCodeAppendix(title, lang, code string) {
|
||||
r.appendices = append(r.appendices, Appendix{
|
||||
Kind: AppendixKindCode,
|
||||
Title: title,
|
||||
Lang: lang,
|
||||
Code: code,
|
||||
})
|
||||
}
|
||||
|
||||
// AddLandscapeAppendix registers an image annex in "Title | /path/to/image" format
|
||||
// that will be rendered on a landscape A4 page with 15 mm symmetric margins.
|
||||
func (r *IHKRenderer) AddLandscapeAppendix(titlePath string) {
|
||||
|
||||
Reference in New Issue
Block a user