Implement many more nodes
All checks were successful
CI Pipeline / build (pull_request) Successful in 12s
All checks were successful
CI Pipeline / build (pull_request) Successful in 12s
Adds these new styling and formatting nodes * strike * highlight * linebreaks * pagebreaks * Hyperlinks
This commit is contained in:
@@ -15,6 +15,8 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
doc.define_style :highlight, bold: true, color: "FF6600"
|
||||
doc.define_style :success, color: "228B22", italic: true
|
||||
doc.define_style :centered_large, align: :center, size: 16, bold: true
|
||||
doc.define_style :deleted_text, strike: true, color: "999999"
|
||||
doc.define_style :important, highlight: "yellow", bold: true
|
||||
|
||||
# ============================================================================
|
||||
# Title and Introduction
|
||||
@@ -33,6 +35,8 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
doc.i { doc.text "italic" }
|
||||
doc.text ", "
|
||||
doc.u { doc.text "underlined" }
|
||||
doc.text ", "
|
||||
doc.s { doc.text "strikethrough" }
|
||||
doc.text ", and "
|
||||
doc.b do
|
||||
doc.i do
|
||||
@@ -42,6 +46,13 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
doc.text " formatting."
|
||||
end
|
||||
|
||||
doc.p do
|
||||
doc.text "Showing edits: "
|
||||
doc.s { doc.text "old text" }
|
||||
doc.text " "
|
||||
doc.b { doc.text "new text" }
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 2. Headings
|
||||
# ============================================================================
|
||||
@@ -73,11 +84,54 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
doc.text " in one paragraph."
|
||||
end
|
||||
doc.p "Centered and large text", style: :centered_large
|
||||
doc.p "This was removed from the document", style: :deleted_text
|
||||
doc.p "This is critically important!", style: :important
|
||||
|
||||
# ============================================================================
|
||||
# 5. Lists
|
||||
# 5. Text Highlighting
|
||||
# ============================================================================
|
||||
doc.h2 "5. Lists"
|
||||
doc.h2 "5. Text Highlighting"
|
||||
doc.p do
|
||||
doc.text "You can highlight text in "
|
||||
doc.text "yellow", style: :important
|
||||
doc.text " or use styles with various highlight colors."
|
||||
end
|
||||
doc.define_style :highlight_cyan, highlight: "cyan"
|
||||
doc.define_style :highlight_green, highlight: "green"
|
||||
doc.define_style :highlight_magenta, highlight: "magenta"
|
||||
doc.p do
|
||||
doc.text "Multiple colors: "
|
||||
doc.text "cyan", style: :highlight_cyan
|
||||
doc.text " "
|
||||
doc.text "green", style: :highlight_green
|
||||
doc.text " "
|
||||
doc.text "magenta", style: :highlight_magenta
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 6. Line Breaks
|
||||
# ============================================================================
|
||||
doc.h2 "6. Line Breaks"
|
||||
doc.p do
|
||||
doc.text "This is the first line."
|
||||
doc.br
|
||||
doc.text "This is the second line (soft break)."
|
||||
doc.br
|
||||
doc.text "This is the third line."
|
||||
end
|
||||
|
||||
doc.p do
|
||||
doc.b { doc.text "Address:" }
|
||||
doc.br
|
||||
doc.text "123 Main Street"
|
||||
doc.br
|
||||
doc.text "Anytown, ST 12345"
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 7. Lists
|
||||
# ============================================================================
|
||||
doc.h2 "7. Lists"
|
||||
|
||||
doc.h3 "Bullet List"
|
||||
doc.ul do
|
||||
@@ -98,9 +152,41 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 6. Tables
|
||||
# 8. Hyperlinks
|
||||
# ============================================================================
|
||||
doc.h2 "6. Tables"
|
||||
doc.h2 "8. Hyperlinks"
|
||||
doc.p do
|
||||
doc.text "Visit "
|
||||
doc.link "https://www.example.com", "Example.com"
|
||||
doc.text " for more information."
|
||||
end
|
||||
|
||||
doc.p do
|
||||
doc.text "Check out "
|
||||
doc.link "https://github.com" do
|
||||
doc.b { doc.text "GitHub" }
|
||||
end
|
||||
doc.text " for code hosting."
|
||||
end
|
||||
|
||||
doc.p do
|
||||
doc.text "Or just paste the URL: "
|
||||
doc.link "https://www.ruby-lang.org"
|
||||
end
|
||||
|
||||
doc.ul do
|
||||
doc.li do
|
||||
doc.link "https://rubyonrails.org", "Ruby on Rails"
|
||||
end
|
||||
doc.li do
|
||||
doc.link "https://rubygems.org", "RubyGems"
|
||||
end
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 9. Tables
|
||||
# ============================================================================
|
||||
doc.h2 "9. Tables"
|
||||
doc.table do
|
||||
doc.tr do
|
||||
doc.td { doc.b { doc.text "Feature" } }
|
||||
@@ -115,7 +201,27 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
doc.tr do
|
||||
doc.td "Formatting"
|
||||
doc.td { doc.text "Complete", style: :success }
|
||||
doc.td "Bold, italic, underline"
|
||||
doc.td "Bold, italic, underline, strikethrough"
|
||||
end
|
||||
doc.tr do
|
||||
doc.td "Highlighting"
|
||||
doc.td { doc.text "Complete", style: :success }
|
||||
doc.td "16 highlight colors"
|
||||
end
|
||||
doc.tr do
|
||||
doc.td "Line Breaks"
|
||||
doc.td { doc.text "Complete", style: :success }
|
||||
doc.td "Soft breaks within paragraphs"
|
||||
end
|
||||
doc.tr do
|
||||
doc.td "Page Breaks"
|
||||
doc.td { doc.text "Complete", style: :success }
|
||||
doc.td "Force new pages"
|
||||
end
|
||||
doc.tr do
|
||||
doc.td "Hyperlinks"
|
||||
doc.td { doc.text "Complete", style: :success }
|
||||
doc.td "Clickable links"
|
||||
end
|
||||
doc.tr do
|
||||
doc.td "Headings"
|
||||
@@ -135,9 +241,9 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 7. Images
|
||||
# 10. Images
|
||||
# ============================================================================
|
||||
doc.h2 "7. Images"
|
||||
doc.h2 "10. Images"
|
||||
|
||||
doc.p "Image with explicit dimensions:"
|
||||
doc.p do
|
||||
@@ -162,9 +268,19 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
end
|
||||
|
||||
# ============================================================================
|
||||
# 8. Combined Features
|
||||
# 11. Page Breaks
|
||||
# ============================================================================
|
||||
doc.h2 "8. Combined Features"
|
||||
doc.h2 "11. Page Breaks"
|
||||
doc.p "The next element will force a new page."
|
||||
|
||||
doc.page_break
|
||||
|
||||
# ============================================================================
|
||||
# 12. Combined Features (on new page)
|
||||
# ============================================================================
|
||||
doc.h2 "12. Combined Features"
|
||||
doc.p "This section starts on a new page thanks to the page break above."
|
||||
|
||||
doc.p do
|
||||
doc.text "This final paragraph combines "
|
||||
doc.b { doc.text "multiple" }
|
||||
@@ -172,9 +288,21 @@ Notare::Document.create(OUTPUT_FILE) do |doc|
|
||||
doc.i { doc.text "formatting" }
|
||||
doc.text " options with "
|
||||
doc.text "custom styles", style: :highlight
|
||||
doc.text ", "
|
||||
doc.s { doc.text "strikethrough" }
|
||||
doc.text ", "
|
||||
doc.text "highlighting", style: :important
|
||||
doc.text ", and "
|
||||
doc.link "https://example.com", "hyperlinks"
|
||||
doc.text " to demonstrate the full power of Notare."
|
||||
end
|
||||
|
||||
doc.p do
|
||||
doc.text "Contact us:"
|
||||
doc.br
|
||||
doc.link "mailto:hello@example.com", "hello@example.com"
|
||||
end
|
||||
|
||||
doc.p "End of demo document.", style: :centered_large
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user