refactor(extensions): reorganize icon management with filter-metadata
- Move icons from extension directory to organized assets location - Create book/assets/images/icons/callouts/ for better asset management - Use filter-metadata section for extension configuration instead of inline YAML - Add icon-path and icon-format configuration in filter-metadata - Update Lua filter to read from filter-metadata instead of direct YAML - Make icon format configurable (PDF for LaTeX, PNG for HTML) - Fix inconsistent icon filename capitalization - Remove old icon directory from extension This follows software engineering best practices: - Separation of concerns (logic vs assets) - Better maintainability and discoverability - Consistent configuration pattern with other filters - Future-proof asset management structure
@@ -704,12 +704,17 @@ insertStylesPandoc = function(doc)
|
||||
-- if stylez.extractStyleFromYaml then stylez.extractStyleFromYaml() end
|
||||
if stylez.insertPreamble and (quarto.doc.is_format("html") or quarto.doc.is_format("pdf"))
|
||||
then
|
||||
-- Set icon path from YAML configuration if available
|
||||
-- Set icon path from filter-metadata configuration if available
|
||||
local meta = doc.meta
|
||||
local cunumbl = meta["mlsysbook-ext/custom-numbered-blocks"]
|
||||
if cunumbl and cunumbl["icon-path"] then
|
||||
local iconPath = str(cunumbl["icon-path"])
|
||||
quarto.doc.include_text("in-header", "\\renewcommand{\\fbxIconPath}{" .. iconPath .. "}")
|
||||
local filterMetadata = meta["filter-metadata"]
|
||||
if filterMetadata and filterMetadata["mlsysbook-ext/custom-numbered-blocks"] then
|
||||
local config = filterMetadata["mlsysbook-ext/custom-numbered-blocks"]
|
||||
if config["icon-path"] then
|
||||
local iconPath = str(config["icon-path"])
|
||||
local iconFormat = str(config["icon-format"] or "pdf")
|
||||
quarto.doc.include_text("in-header", "\\renewcommand{\\fbxIconPath}{" .. iconPath .. "}")
|
||||
quarto.doc.include_text("in-header", "\\renewcommand{\\fbxIconFormat}{" .. iconFormat .. "}")
|
||||
end
|
||||
end
|
||||
stylez.insertPreamble(doc, fbx.classDefaults, fmt)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
%%%% ---foldboxy preamble ----- %%%%%
|
||||
|
||||
% Icon path configuration - can be overridden in YAML
|
||||
\providecommand{\fbxIconPath}{_extensions/mlsysbook-ext/custom-numbered-blocks/style/icons}
|
||||
% Icon path and format configuration - can be overridden in filter-metadata
|
||||
\providecommand{\fbxIconPath}{assets/images/icons/callouts}
|
||||
\providecommand{\fbxIconFormat}{pdf}
|
||||
|
||||
% Legacy fallback colors (keep for compatibility)
|
||||
\definecolor{fbx-default-color1}{HTML}{c7c7d0}
|
||||
@@ -28,7 +29,7 @@
|
||||
overlay={
|
||||
\node [left,outer sep=0em, black,draw=none,anchor=west,
|
||||
rectangle,fill=none,inner sep=0pt]
|
||||
at ([xshift=4mm]frame.west) {\includegraphics[width=4.2mm]{\fbxIconPath/icon_#1.pdf}};
|
||||
at ([xshift=4mm]frame.west) {\includegraphics[width=4.2mm]{\fbxIconPath/icon_#1.\fbxIconFormat}};
|
||||
},
|
||||
},
|
||||
colframe=#1-color2, % Border color (auto-generated from YAML)
|
||||
@@ -69,7 +70,7 @@
|
||||
overlay={
|
||||
\node [left,outer sep=0em, black,draw=none,anchor=west,
|
||||
rectangle,fill=none,inner sep=0pt]
|
||||
at ([xshift=3mm]frame.west) {\includegraphics[width=4.2mm]{\fbxIconPath/icon_#1.pdf}};
|
||||
at ([xshift=3mm]frame.west) {\includegraphics[width=4.2mm]{\fbxIconPath/icon_#1.\fbxIconFormat}};
|
||||
},
|
||||
},
|
||||
colframe=#1-color2, % Border color (auto-generated from YAML)
|
||||
|
||||
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
@@ -395,6 +395,11 @@ filter-metadata:
|
||||
file: "part_summaries.yml"
|
||||
enabled: true
|
||||
|
||||
# Custom numbered blocks configuration for mlsysbook-ext/custom-numbered-blocks filter
|
||||
mlsysbook-ext/custom-numbered-blocks:
|
||||
icon-path: "assets/images/icons/callouts" # Path to callout icons
|
||||
icon-format: "png" # Icon format for HTML builds
|
||||
|
||||
diagram:
|
||||
engine:
|
||||
dot: true
|
||||
@@ -513,7 +518,6 @@ format:
|
||||
citeproc: true
|
||||
|
||||
mlsysbook-ext/custom-numbered-blocks:
|
||||
icon-path: "_extensions/mlsysbook-ext/custom-numbered-blocks/style/icons"
|
||||
groups:
|
||||
quiz-question:
|
||||
colors: ["F0F0F8", "5B4B8A"] # Darker purple for quiz questions
|
||||
|
||||
@@ -267,6 +267,11 @@ filter-metadata:
|
||||
file: "part_summaries.yml" # Path to part summaries YAML file
|
||||
enabled: true # Enable/disable part summary injection
|
||||
|
||||
# Custom numbered blocks configuration for mlsysbook-ext/custom-numbered-blocks filter
|
||||
mlsysbook-ext/custom-numbered-blocks:
|
||||
icon-path: "assets/images/icons/callouts" # Path to callout icons
|
||||
icon-format: "pdf" # Icon format for PDF builds
|
||||
|
||||
diagram:
|
||||
engine:
|
||||
dot: true
|
||||
@@ -443,7 +448,6 @@ format:
|
||||
\let\Needspace\needspace
|
||||
|
||||
mlsysbook-ext/custom-numbered-blocks:
|
||||
icon-path: "_extensions/mlsysbook-ext/custom-numbered-blocks/style/icons"
|
||||
groups:
|
||||
quiz-question:
|
||||
colors: ["F0F0F8", "5B4B8A"] # Darker purple for quiz questions
|
||||
|
||||