Implement table styles
All checks were successful
CI Pipeline / build (pull_request) Successful in 14s

This commit is contained in:
2025-12-03 12:14:31 +01:00
parent 67a60c8c6e
commit 9a70d91fd5
12 changed files with 555 additions and 13 deletions

View File

@@ -18,6 +18,25 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
doc.define_style :deleted_text, strike: true, color: "999999"
doc.define_style :important, highlight: "yellow", bold: true
# ============================================================================
# Custom Table Styles
# ============================================================================
doc.define_table_style :fancy_table,
borders: { style: "double", color: "0066CC", size: 6 },
shading: "E6F2FF",
cell_margins: 80,
align: :center
doc.define_table_style :minimal_table,
borders: {
top: { style: "single", color: "CCCCCC", size: 4 },
bottom: { style: "single", color: "CCCCCC", size: 4 },
left: { style: "none" },
right: { style: "none" },
insideH: { style: "dotted", color: "DDDDDD", size: 2 },
insideV: { style: "none" }
}
# ============================================================================
# Title and Introduction
# ============================================================================
@@ -218,6 +237,8 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
# 9. Tables
# ============================================================================
doc.h2 "9. Tables"
doc.h3 "Default Table"
doc.table do
doc.tr do
doc.td { doc.b { doc.text "Feature" } }
@@ -276,6 +297,52 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
end
end
doc.h3 "Styled Tables"
doc.p "Fancy table with double borders and shading:"
doc.table(style: :fancy_table) do
doc.tr do
doc.td { doc.b { doc.text "Product" } }
doc.td { doc.b { doc.text "Price" } }
doc.td { doc.b { doc.text "Quantity" } }
end
doc.tr do
doc.td "Widget A"
doc.td "$10.00"
doc.td "100"
end
doc.tr do
doc.td "Widget B"
doc.td "$15.00"
doc.td "50"
end
end
doc.p "Minimal table with horizontal lines only:"
doc.table(style: :minimal_table) do
doc.tr do
doc.td { doc.b { doc.text "Name" } }
doc.td { doc.b { doc.text "Role" } }
end
doc.tr do
doc.td "Alice"
doc.td "Developer"
end
doc.tr do
doc.td "Bob"
doc.td "Designer"
end
end
doc.p "Borderless table (built-in style):"
doc.table(style: :borderless) do
doc.tr do
doc.td "No"
doc.td "borders"
doc.td "here"
end
end
# ============================================================================
# 10. Images
# ============================================================================