diff --git a/content/chapters/part1/chapter-04.md b/content/chapters/part1/chapter-04.md index e2c6294..5a268b1 100644 --- a/content/chapters/part1/chapter-04.md +++ b/content/chapters/part1/chapter-04.md @@ -5613,7 +5613,7 @@ We will first look at arrays of pointers, then at pointers to arrays, and then c An array of pointers is simply an array where each element is itself a pointer. Instead of holding values directly, the array holds addresses pointing to values stored elsewhere. ##### Example: Array of Strings - +. ```c #include @@ -5669,7 +5669,7 @@ This is another array of string pointers, terminated by `NULL`. The SNMP client A pointer to an array is very different from an array of pointers. Instead of pointing to scattered objects, it points to one single, contiguous array block. The syntax can look intimidating, but the underlying idea is simple: the pointer represents the entire array as a unit. ##### Example: Pointer to an Array of Integers - +. ```c #include @@ -5692,7 +5692,7 @@ Breaking it down: - `(*p)[2]` first dereferences the pointer (giving us the array) and then indexes into it. ##### Another Example with Structures - +. ```c #include @@ -9182,7 +9182,7 @@ But don't touch `util.c`. Recompile only `main.c`: Now `./demo` may run incorrectly, or crash, depending on calling conventions. -👉 Lesson: Partial rebuilds can leave object files out of sync with headers, creating *phantom bugs*. This is why we use `make`. +Lesson: Partial rebuilds can leave object files out of sync with headers, creating *phantom bugs*. This is why we use `make`. #### Recap Quiz: Common Pitfalls diff --git a/public/images/book-cover.jpg b/public/images/book-cover.jpg new file mode 100644 index 0000000..73230e1 Binary files /dev/null and b/public/images/book-cover.jpg differ diff --git a/scripts/build-book.sh b/scripts/build-book.sh new file mode 100755 index 0000000..87485a4 --- /dev/null +++ b/scripts/build-book.sh @@ -0,0 +1,612 @@ +#!/bin/bash + +# ============================================================================= +# BSD 3-Clause License +# ============================================================================= +# +# Copyright (c) 2025, Edson Brandi +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ============================================================================= +# FreeBSD Device Drivers Book Build Script +# ============================================================================= +# This script builds the book in PDF, EPUB, and/or HTML5 formats using Pandoc +# and the Eisvogel LaTeX template. +# ============================================================================= + +set -e # Exit on any error + +# Get the directory where this script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(dirname "$SCRIPT_DIR")" + +# Change to the root directory to ensure correct relative paths +cd "$ROOT_DIR" + +# ============================================================================= +# CONFIGURATION +# ============================================================================= + +# Book information +BOOK_TITLE="FreeBSD Device Drivers" +BOOK_AUTHOR="Edson Brandi" +BOOK_DATE="DRAFT Version 1.0 - August, 30th 2025" + +# File paths +TITLE_FILE="$SCRIPT_DIR/title.md" +METADATA_FILE="$SCRIPT_DIR/metadata.yaml" +OUTPUT_DIR="public/downloads" + +# Template and engine +EISVOGEL_TEMPLATE="$HOME/.local/share/pandoc/templates/eisvogel.latex" +PDF_ENGINE="xelatex" + +# ============================================================================= +# FUNCTIONS +# ============================================================================= + +# Function to filter markdown files by line count (exclude files with less than 20 lines) +filter_markdown_files() { + local directory="$1" + local show_warnings="${2:-true}" # Default to showing warnings + local filtered_files=() + + if [ -d "$directory" ]; then + while IFS= read -r -d '' file; do + # Check if file exists and is readable + if [ -f "$file" ] && [ -r "$file" ]; then + local line_count=$(wc -l < "$file" 2>/dev/null || echo "0") + if [ "$line_count" -ge 20 ]; then + filtered_files+=("$file") + else + if [ "$show_warnings" = "true" ]; then + echo " ⚠ Skipping short file: $file ($line_count lines, minimum 20 required)" + fi + fi + else + if [ "$show_warnings" = "true" ]; then + echo " ⚠ Skipping inaccessible file: $file" + fi + fi + done < <(find "$directory" -name "*.md" -print0 | sort -z) + fi + + # Return array elements properly quoted + printf '%s\n' "${filtered_files[@]}" +} + +show_help() { + cat << EOF +Usage: $0 [OPTIONS] + +Build the FreeBSD Device Drivers book in various formats. + +OPTIONS: + --pdf Build PDF version only + --epub Build EPUB version only + --html Build HTML5 version only + --all Build all formats (PDF, EPUB, HTML5) + --test Test if all dependencies are properly installed + -h, --help Show this help message + +NOTE: All options are case-insensitive (--PDF, --Pdf, --pdf all work the same) + +EXAMPLES: + $0 --pdf # Build PDF only + $0 --epub --html # Build EPUB and HTML5 + $0 --all # Build all formats + $0 --test # Test dependencies + $0 --PDF # Same as --pdf + $0 --EPUB --HTML # Same as --epub --html + +OUTPUT DIRECTORY: + Generated files will be placed in: $OUTPUT_DIR/ + + - PDF: $OUTPUT_DIR/freebsd-device-drivers.pdf + - EPUB: $OUTPUT_DIR/freebsd-device-drivers.epub + - HTML: $OUTPUT_DIR/freebsd-device-drivers.html + +REQUIREMENTS: + - Pandoc 3.0+ + - XeLaTeX (texlive-xetex) + - Eisvogel template at: $EISVOGEL_TEMPLATE + - Required fonts and LaTeX packages + +For detailed installation instructions, see: $SCRIPT_DIR/BUILD-README.md +EOF +} + +test_dependencies() { + echo "🔍 Testing build system dependencies..." + echo "" + + local all_good=true + + # Test Pandoc + echo "1. Testing Pandoc..." + if command -v pandoc >/dev/null 2>&1; then + local pandoc_version=$(pandoc --version | head -n1) + echo " ✓ Pandoc found: $pandoc_version" + + # Check version + local major_version=$(pandoc --version | head -n1 | grep -o '[0-9]\+\.[0-9]\+' | head -n1 | cut -d. -f1) + if [ "$major_version" -ge 3 ]; then + echo " ✓ Pandoc version 3.0+ (compatible)" + else + echo " ✗ Pandoc version $major_version.x (requires 3.0+)" + all_good=false + fi + else + echo " ✗ Pandoc not found" + all_good=false + fi + + # Test XeLaTeX + echo "" + echo "2. Testing XeLaTeX..." + if command -v xelatex >/dev/null 2>&1; then + local xelatex_version=$(xelatex --version | head -n1) + echo " ✓ XeLaTeX found: $xelatex_version" + else + echo " ✗ XeLaTeX not found" + all_good=false + fi + + # Test Eisvogel template + echo "" + echo "3. Testing Eisvogel template..." + if [ -f "$EISVOGEL_TEMPLATE" ]; then + echo " ✓ Eisvogel template found: $EISVOGEL_TEMPLATE" + local template_size=$(du -h "$EISVOGEL_TEMPLATE" | cut -f1) + echo " ✓ Template size: $template_size" + else + echo " ✗ Eisvogel template not found at: $EISVOGEL_TEMPLATE" + echo " 💡 Install with: wget -O $EISVOGEL_TEMPLATE https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/eisvogel.tex" + all_good=false + fi + + # Test output directory + echo "" + echo "4. Testing output directory..." + if [ -d "$OUTPUT_DIR" ]; then + echo " ✓ Output directory exists: $OUTPUT_DIR" + else + echo " ⚠ Output directory does not exist, will be created: $OUTPUT_DIR" + fi + + # Test content files + echo "" + echo "5. Testing content files..." + local chapter_files_filtered=() + local appendix_files_filtered=() + + # Read filtered files into arrays + while IFS= read -r file; do + if [ -n "$file" ]; then + chapter_files_filtered+=("$file") + fi + done < <(filter_markdown_files "content/chapters") + + while IFS= read -r file; do + if [ -n "$file" ]; then + appendix_files_filtered+=("$file") + fi + done < <(filter_markdown_files "content/appendices") + + local chapter_count=${#chapter_files_filtered[@]} + local appendix_count=${#appendix_files_filtered[@]} + + if [ -f "$TITLE_FILE" ]; then + echo " ✓ Title file found: $TITLE_FILE" + else + echo " ✗ Title file not found: $TITLE_FILE" + all_good=false + fi + + if [ -f "$METADATA_FILE" ]; then + echo " ✓ Metadata file found: $METADATA_FILE" + else + echo " ✗ Metadata file not found: $METADATA_FILE" + all_good=false + fi + + if [ "$chapter_count" -gt 0 ]; then + echo " ✓ Chapters found: $chapter_count files (excluding short files < 20 lines)" + else + echo " ✗ No valid chapter files found in content/chapters/ (all files have < 20 lines)" + all_good=false + fi + + if [ "$appendix_count" -gt 0 ]; then + echo " ✓ Appendices found: $appendix_count files (excluding short files < 20 lines)" + else + echo " ⚠ No valid appendix files found in content/appendices/ (all files have < 20 lines)" + fi + + echo "" + if [ "$all_good" = true ]; then + echo "🎉 All dependencies are properly installed! You can build your book." + echo " Run: $0 --help for build options" + else + echo "❌ Some dependencies are missing. Please install them before building." + echo " See: $SCRIPT_DIR/BUILD-README.md for installation instructions" + exit 1 + fi +} + +build_pdf() { + echo "📚 Building PDF: $OUTPUT_DIR/freebsd-device-drivers.pdf" + + # Ensure output directory exists + mkdir -p "$OUTPUT_DIR" + + # Collect all markdown files (filter out files with less than 20 lines) + local title_file="$TITLE_FILE" + local chapter_files=() + local appendix_files=() + + # Read filtered files into arrays (suppress warnings during build) + while IFS= read -r file; do + if [ -n "$file" ]; then + chapter_files+=("$file") + fi + done < <(filter_markdown_files "content/chapters" "false") + + while IFS= read -r file; do + if [ -n "$file" ]; then + appendix_files+=("$file") + fi + done < <(filter_markdown_files "content/appendices" "false") + + # Combine all files + local all_files=("$title_file" "${chapter_files[@]}" "${appendix_files[@]}") + local total_files=${#all_files[@]} + + echo " Including files: $total_files total (1 title + ${#chapter_files[@]} chapters + ${#appendix_files[@]} appendices)" + + # Build PDF with Eisvogel template + echo " Running pandoc with Eisvogel template..." + + pandoc "${all_files[@]}" \ + --metadata-file="$METADATA_FILE" \ + --template eisvogel \ + --pdf-engine=xelatex \ + --from markdown+fenced_code_blocks \ + --toc \ + --toc-depth=2 \ + --number-sections \ + --metadata title="$BOOK_TITLE" \ + --metadata author="$BOOK_AUTHOR" \ + --metadata date="$BOOK_DATE" \ + --variable titlepage=true \ + --variable toc-own-page=true \ + --variable graphics=true \ + --variable papersize=a4 \ + --variable documentclass=book \ + --variable book=true \ + --variable code-block-font-size=\\footnotesize \ + --variable float-placement-figure="H" \ + --variable figure-placement="H" \ + --highlight-style=tango \ + --variable linestretch=1.15 \ + --variable geometry:"inner=2cm,outer=2cm,top=2.5cm,bottom=2.5cm" \ + -o "$OUTPUT_DIR/freebsd-device-drivers.pdf" 2>&1 + + local exit_code=$? + if [ $exit_code -eq 0 ]; then + echo " ✓ PDF successfully generated: $OUTPUT_DIR/freebsd-device-drivers.pdf" + local file_size=$(du -h "$OUTPUT_DIR/freebsd-device-drivers.pdf" | cut -f1) + echo " ✓ PDF file size: $file_size" + else + echo " ✗ PDF generation failed (exit code: $exit_code)" + return $exit_code + fi +} + +build_epub() { + echo "📖 Building EPUB: $OUTPUT_DIR/freebsd-device-drivers.epub" + + # Ensure output directory exists + mkdir -p "$OUTPUT_DIR" + + # Collect all markdown files (filter out files with less than 20 lines) + local title_file="$TITLE_FILE" + local chapter_files=() + local appendix_files=() + + # Read filtered files into arrays (suppress warnings during build) + while IFS= read -r file; do + if [ -n "$file" ]; then + chapter_files+=("$file") + fi + done < <(filter_markdown_files "content/chapters" "false") + + while IFS= read -r file; do + if [ -n "$file" ]; then + appendix_files+=("$file") + fi + done < <(filter_markdown_files "content/appendices" "false") + + # Combine all files + local all_files=("$title_file" "${chapter_files[@]}" "${appendix_files[@]}") + + # Build EPUB + pandoc "${all_files[@]}" \ + --metadata-file="$METADATA_FILE" \ + --metadata title="$BOOK_TITLE" \ + --metadata author="$BOOK_AUTHOR" \ + --metadata date="$BOOK_DATE" \ + --toc \ + --toc-depth=2 \ + --number-sections \ + --highlight-style=tango \ + --epub-chapter-level=1 \ + --verbose \ + -o "$OUTPUT_DIR/freebsd-device-drivers.epub" 2>&1 + + local exit_code=$? + if [ $exit_code -eq 0 ]; then + echo " ✓ EPUB successfully generated: $OUTPUT_DIR/freebsd-device-drivers.epub" + local file_size=$(du -h "$OUTPUT_DIR/freebsd-device-drivers.epub" | cut -f1) + echo " ✓ EPUB file size: $file_size" + else + echo " ✗ EPUB generation failed (exit code: $exit_code)" + return $exit_code + fi +} + +build_html() { + echo "🌐 Building HTML5: $OUTPUT_DIR/freebsd-device-drivers.html" + + # Ensure output directory exists + mkdir -p "$OUTPUT_DIR" + + # Collect all markdown files (filter out files with less than 20 lines) + local title_file="$TITLE_FILE" + local chapter_files=() + local appendix_files=() + + # Read filtered files into arrays (suppress warnings during build) + while IFS= read -r file; do + if [ -n "$file" ]; then + chapter_files+=("$file") + fi + done < <(filter_markdown_files "content/chapters" "false") + + while IFS= read -r file; do + if [ -n "$file" ]; then + appendix_files+=("$file") + fi + done < <(filter_markdown_files "content/appendices" "false") + + # Combine all files + local all_files=("$title_file" "${chapter_files[@]}" "${appendix_files[@]}") + + # Debug: Show what files will be processed + echo " Files to process:" + echo " Title: $title_file" + echo " Chapters: ${#chapter_files[@]} files" + echo " Appendices: ${#appendix_files[@]} files" + echo " Total: ${#all_files[@]} files" + + # Use Pandoc's default CSS for better code highlighting + echo " Using Pandoc's default CSS for better code highlighting" + + # Build HTML5 + pandoc "${all_files[@]}" \ + --metadata-file="$METADATA_FILE" \ + --to=html5 \ + --standalone \ + --embed-resources \ + --highlight-style=tango \ + --toc \ + --toc-depth=2 \ + --number-sections \ + --metadata title="$BOOK_TITLE" \ + --metadata author="$BOOK_AUTHOR" \ + --metadata date="$BOOK_DATE" \ + -o "$OUTPUT_DIR/freebsd-device-drivers.html" 2>&1 + + local exit_code=$? + if [ $exit_code -eq 0 ]; then + echo " ✓ HTML5 successfully generated: $OUTPUT_DIR/freebsd-device-drivers.html" + local file_size=$(du -h "$OUTPUT_DIR/freebsd-device-drivers.html" | cut -f1) + echo " ✓ HTML5 file size: $file_size" + echo " ✓ HTML5 file has embedded resources and can be opened in any web browser" + else + echo " ✗ HTML5 generation failed (exit code: $exit_code)" + return $exit_code + fi +} + +show_build_summary() { + echo "" + echo "🎉 Build process completed!" + echo "" + echo "Generated files:" + + if [ "$BUILD_PDF" = true ] && [ -f "$OUTPUT_DIR/freebsd-device-drivers.pdf" ]; then + echo " 📚 PDF: $OUTPUT_DIR/freebsd-device-drivers.pdf" + fi + + if [ "$BUILD_EPUB" = true ] && [ -f "$OUTPUT_DIR/freebsd-device-drivers.epub" ]; then + echo " 📖 EPUB: $OUTPUT_DIR/freebsd-device-drivers.epub" + fi + + if [ "$BUILD_HTML" = true ] && [ -f "$OUTPUT_DIR/freebsd-device-drivers.html" ]; then + echo " 🌐 HTML: $OUTPUT_DIR/freebsd-device-drivers.html" + fi + + echo "" + echo "File structure used:" + local chapter_files_filtered=() + local appendix_files_filtered=() + + # Read filtered files into arrays (suppress warnings during summary) + while IFS= read -r file; do + if [ -n "$file" ]; then + chapter_files_filtered+=("$file") + fi + done < <(filter_markdown_files "content/chapters" "false") + + while IFS= read -r file; do + if [ -n "$file" ]; then + appendix_files_filtered+=("$file") + fi + done < <(filter_markdown_files "content/appendices" "false") + + local chapter_count=${#chapter_files_filtered[@]} + local appendix_count=${#appendix_files_filtered[@]} + echo " 📁 Chapters: content/chapters/ ($chapter_count files, excluding short files)" + if [ "$appendix_count" -gt 0 ]; then + echo " 📁 Appendices: content/appendices/ ($appendix_count files, excluding short files)" + fi + + echo "" + echo "Eisvogel template configuration:" + echo " 🎨 Template: eisvogel.latex" + echo " 🔧 PDF Engine: XeLaTeX" + echo " 💻 Code highlighting: enabled with listings package" + echo " 🔤 C language support: enabled" + echo " 📖 Book format: enabled with title page" +} + +# ============================================================================= +# MAIN SCRIPT +# ============================================================================= + +# Initialize build flags +BUILD_PDF=false +BUILD_EPUB=false +BUILD_HTML=false +SHOW_HELP=false +TEST_DEPS=false + +# Parse command line arguments (case-insensitive) +while [[ $# -gt 0 ]]; do + # Convert argument to lowercase for case-insensitive comparison + arg_lower="${1,,}" + + case $arg_lower in + --pdf) + BUILD_PDF=true + shift + ;; + --epub) + BUILD_EPUB=true + shift + ;; + --html) + BUILD_HTML=true + shift + ;; + --all) + BUILD_PDF=true + BUILD_EPUB=true + BUILD_HTML=true + shift + ;; + --test) + TEST_DEPS=true + shift + ;; + -h|--help) + SHOW_HELP=true + shift + ;; + *) + echo "❌ Unknown option: $1" + echo " Run '$0 --help' for usage information" + echo " Note: Options are case-insensitive (e.g., --PDF, --Pdf, --pdf all work)" + exit 1 + ;; + esac +done + +# Show help if requested or no options specified +if [ "$SHOW_HELP" = true ] || ([ "$BUILD_PDF" = false ] && [ "$BUILD_EPUB" = false ] && [ "$BUILD_HTML" = false ] && [ "$TEST_DEPS" = false ]); then + show_help + exit 0 +fi + +# Test dependencies if requested +if [ "$TEST_DEPS" = true ]; then + test_dependencies + exit 0 +fi + +# Show build configuration +echo "🚀 FreeBSD Device Drivers Book Build System" +echo "=============================================" +echo "Build configuration:" +if [ "$BUILD_PDF" = true ]; then echo " 📚 PDF: Enabled"; fi +if [ "$BUILD_EPUB" = true ]; then echo " 📖 EPUB: Enabled"; fi +if [ "$BUILD_HTML" = true ]; then echo " 🌐 HTML: Enabled"; fi +echo "Output directory: $OUTPUT_DIR" +echo "" + +# Build requested formats +build_errors=0 + +if [ "$BUILD_PDF" = true ]; then + if build_pdf; then + echo "" + else + build_errors=$((build_errors + 1)) + fi +fi + +if [ "$BUILD_EPUB" = true ]; then + if build_epub; then + echo "" + else + build_errors=$((build_errors + 1)) + fi +fi + +if [ "$BUILD_HTML" = true ]; then + if build_html; then + echo "" + else + build_errors=$((build_errors + 1)) + fi +fi + +# Show build summary +show_build_summary + +# Exit with error code if any builds failed +if [ $build_errors -gt 0 ]; then + echo "" + echo "❌ Some builds failed. Check the error messages above." + exit 1 +else + echo "" + echo "✅ All requested formats built successfully!" + exit 0 +fi diff --git a/scripts/metadata.yaml b/scripts/metadata.yaml new file mode 100644 index 0000000..5651174 --- /dev/null +++ b/scripts/metadata.yaml @@ -0,0 +1,155 @@ +--- +# ============================================================================= +# FreeBSD Device Drivers Book - Metadata Configuration +# ============================================================================= +# This file contains all the configuration settings for the Eisvogel pandoc +# LaTeX template. It controls the appearance, formatting, and behavior of +# the generated PDF document. +# +# For detailed documentation, see: https://github.com/Wandmalfarbe/pandoc-latex-template +# ============================================================================= + +# ============================================================================= +# BASIC DOCUMENT INFORMATION +# ============================================================================= +# Core document metadata that appears in the title page and document properties +#title: "FreeBSD Device Drivers" +subtitle: "From First Steps to Kernel Mastery" +#author: "Edson Brandi" +#date: "DRAFT Version 1.0 - August, 30th 2025" + +# ============================================================================= +# DOCUMENT CLASSIFICATION AND METADATA +# ============================================================================= +# Subject and keywords for document classification and searchability +subject: "FreeBSD Device Drivers" +keywords: [FreeBSD, Device Drivers, Kernel Programming, C Programming, Operating Systems] + +# ============================================================================= +# DOCUMENT STRUCTURE SETTINGS +# ============================================================================= +# Configure the document as a book with proper chapter and section numbering +book: true # Enable book document class +classoption: [oneside] # Single-sided pages (no blank pages between chapters) +papersize: a4 # US Letter paper size (8.5" x 11") +lang: en-US # English (US) language for hyphenation and formatting + +# ============================================================================= +# TITLE PAGE CONFIGURATION +# ============================================================================= +# Control the appearance and behavior of the title page +titlepage: true # Generate a dedicated title page +cover-image: "public/images/book-cover.jpg" # Path to book cover image + +# Title page color scheme (hex color codes) +titlepage-color: "AA2B28" # Dark blue background +titlepage-text-color: "FFFFFF" # White text +titlepage-rule-color: "000000" # Red accent rule +titlepage-rule-height: 4 # Height of the accent rule in points +logo-width: 35mm # Width of logo/cover image on title page + +# ============================================================================= +# TABLE OF CONTENTS SETTINGS +# ============================================================================= +# Control the generation and appearance of the table of contents +#toc: true # Generate table of contents +#toc-own-page: true # Start TOC on a new page +#toc-depth: 2 # Include headings up to level 3 (###) + +# ============================================================================= +# CODE BLOCK AND LISTING CONFIGURATION +# ============================================================================= +# Settings for code blocks, syntax highlighting, and program listings +listings: true # Enable LaTeX listings package for code blocks +listings-disable-line-numbers: true # Show line numbers in code blocks +listings-no-page-break: true # Allow code blocks to break across pages if needed +code-block-font-size: "\\footnotesize" # Smaller font size for code blocks to fit more content + +# Code block appearance and formatting +code-block-font: "Liberation Mono" # Font for code blocks +verbatim-font: "Liberation Mono" # Font for verbatim text +listings-font: "Liberation Mono" # Font for listings +code-font: "Liberation Mono" # Font for inline code +listing-font: "Liberation Mono" # Font for program listings +monospace-font: "Liberation Mono" # General monospace font + +# Syntax highlighting style for code blocks +highlight-style: tango # Use Kate highlighting theme (good for C/C++) + +# ============================================================================= +# FONT AND TYPOGRAPHY SETTINGS +# ============================================================================= +# Configure fonts for different text elements +mainfont: "Times New Roman" # Main body text font (serif) +sansfont: "Arial" # Sans-serif font for headings +monofont: "Liberation Mono" # Monospace font for code +mathfont: "Latin Modern Math" # Font for mathematical expressions + +# Font scaling options (adjust size relative to base font size) +mainfontoptions: "Scale=1.0" # Main font at normal size +sansfontoptions: "Scale=0.9" # Sans-serif font slightly smaller +monofontoptions: "Scale=0.85" # Monospace font smaller for code + +# Typography and spacing +fontsize: 11pt # Base font size for the document +linestretch: 1.15 # Line spacing multiplier (1.15 = 15% more space) + +# ============================================================================= +# IMAGE HANDLING AND PLACEMENT +# ============================================================================= +# Control how images are displayed and positioned in the document +graphics: true # Enable Eisvogel's built-in image scaling +figure-placement: "H" # Force figures to stay in place (H = Here) +float-placement-figure: "H" # Alternative setting for figure placement + +# ============================================================================= +# PAGE LAYOUT AND GEOMETRY +# ============================================================================= +# Control page margins and layout +geometry: margin=2cm # Set all page margins to 1 inch + +# ============================================================================= +# SECTION NUMBERING AND LINKS +# ============================================================================= +# Control section numbering and link appearance +numbersections: true # Enable automatic section numbering +colorlinks: true # Make links appear in color +linkcolor: blue # Color for internal links +urlcolor: blue # Color for external URLs + + +output: + pdf_document: + latex_engine: xelatex + keep_tex: true + +# ============================================================================= +# ADVANCED LATEX CONFIGURATION +# ============================================================================= +# Custom LaTeX packages and commands injected into the document header +# The following LaTeX commands are injected directly into the document header: +# - \usepackage{graphicx}: Enables image inclusion and manipulation +# - \setkeys{Gin}{width=0.85\linewidth,keepaspectratio}: Sets default image width to 85% of line width +# - \usepackage{fontspec}: Enables advanced font selection and management +# - \usepackage{unicode-math}: Provides enhanced mathematical typesetting +# - \setmonofont[Scale=0.85]{Liberation Mono}: Sets monospace font with 85% scaling +# - \usepackage{listings}: Provides advanced code listing capabilities +# - \lstset{...}: Configures code block appearance (small font, line breaks, frames) +header-includes: | + \usepackage{graphicx} + \setkeys{Gin}{width=0.85\linewidth,keepaspectratio} + \usepackage{fontspec} + \usepackage{unicode-math} + \setmonofont[Scale=0.85]{Liberation Mono} + \usepackage{listings} + \usepackage{fvextra} + \fvset{breaklines=true,breakanywhere=true} + \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}} + \lstset{ + basicstyle=\ttfamily\footnotesize, + breaklines=true, + columns=flexible, + keepspaces=true, + frame=single + } +--- diff --git a/scripts/title.md b/scripts/title.md new file mode 100644 index 0000000..2d4bb6f --- /dev/null +++ b/scripts/title.md @@ -0,0 +1,7 @@ +--- +title: "FreeBSD Device Drivers" +subtitle: "From First Steps to Kernel Mastery" +author: "Edson Brandi" +date: "DRAFT Version 1.0 - August, 30th 2025" +--- +\newpage