Implement many more nodes
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:
2025-12-02 14:43:53 +01:00
parent 243b06d8f8
commit 597bc91c40
19 changed files with 788 additions and 24 deletions

View File

@@ -60,6 +60,30 @@ module Notare
with_format(:underline, &block)
end
def s(&block)
with_format(:strike, &block)
end
def br
@current_target.add_run(Nodes::Break.new(type: :line))
end
def page_break
@nodes << Nodes::Break.new(type: :page)
end
def link(url, text = nil, &block)
hyperlink = register_hyperlink(url)
if block
with_target(hyperlink, &block)
elsif text
hyperlink.add_run(Nodes::Run.new(text, underline: true, color: "0000FF"))
else
hyperlink.add_run(Nodes::Run.new(url, underline: true, color: "0000FF"))
end
@current_target.add_run(hyperlink)
end
def ul(&block)
list(:bullet, &block)
end
@@ -111,6 +135,7 @@ module Notare
def list(type, &block)
@num_id_counter ||= 0
@num_id_counter += 1
mark_has_lists!
list_node = Nodes::List.new(type: type, num_id: @num_id_counter)
previous_list = @current_list
@@ -139,7 +164,8 @@ module Notare
{
bold: @format_stack.include?(:bold),
italic: @format_stack.include?(:italic),
underline: @format_stack.include?(:underline)
underline: @format_stack.include?(:underline),
strike: @format_stack.include?(:strike)
}
end