From f611acab311bd3cb2efd668f81e5abd9b1220c7e Mon Sep 17 00:00:00 2001 From: Schneems Date: Wed, 20 Nov 2024 16:28:29 -0600 Subject: [PATCH] Store partial results in memory --- lib/rundoc/code_section.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/rundoc/code_section.rb b/lib/rundoc/code_section.rb index 2ccd6ad..2be28e6 100644 --- a/lib/rundoc/code_section.rb +++ b/lib/rundoc/code_section.rb @@ -30,6 +30,9 @@ def initialize(options = {}) AUTOGEN_WARNING = "\n" attr_accessor :original, :fence, :lang, :code, :commands, :keyword + PARTIAL_RESULT = [] + PARTIAL_ENV = {} + def initialize(match, keyword:, context:) @original = match.to_s @commands = [] @@ -40,6 +43,8 @@ def initialize(match, keyword:, context:) @lang = match[:lang] @code = match[:contents] parse_code_command + PARTIAL_RESULT.clear + PARTIAL_ENV.clear end def render @@ -69,6 +74,9 @@ def render tmp_result << code_output if code_command.render_result? result << tmp_result unless code_command.hidden? + + PARTIAL_RESULT.replace(result) + PARTIAL_ENV.replace(env) end return "" if hidden?