You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
608 B
Ruby

class CardDSL
def initialize
@blocks = []
end
def text(content)
@blocks << { type: "text", content: content }
end
def code(content)
@blocks << { type: "code", content: content }
end
def math(content)
@blocks << { type: "math", content: content }
end
def blocks
@blocks
end
end
def print_card(&block)
card = CardDSL.new
card.instance_eval(&block)
card.blocks.each { |block| p block }
# JS.global[:rubyOutputs].push(card)
end
print_card do
text "Hello, world!"
code "puts 'Hello, world!'"
math "\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix}"
end