lib/mdoc.rb in markdown_exec-2.0.6 vs lib/mdoc.rb in markdown_exec-2.0.7

- old
+ new

@@ -70,34 +70,31 @@ # @param name [String] The name of the code block to start the retrieval from. # @return [Array<Hash>] An array of code blocks required by the specified code block. # def collect_block_dependencies(anyname:) name_block = get_block_by_anyname(anyname) - if name_block.nil? || name_block.keys.empty? - raise "Named code block `#{anyname}` not found. (@#{__LINE__})" - end + raise "Named code block `#{anyname}` not found. (@#{__LINE__})" if name_block.nil? || name_block.keys.empty? - nickname = name_block[:nickname] || name_block[:oname] + nickname = name_block.pub_name + dependencies = collect_dependencies(nickname) # &bc 'dependencies.count:',dependencies.count all_dependency_names = collect_unique_names(dependencies).push(nickname).uniq # &bc 'all_dependency_names.count:',all_dependency_names.count # select non-chrome blocks in order of appearance in source documents # blocks = @table.select do |fcb| - !fcb.fetch(:chrome, - false) && all_dependency_names.include?(fcb.fetch(:nickname, - nil) || fcb.fetch(:oname)) + !fcb.fetch(:chrome, false) && all_dependency_names.include?(fcb.pub_name) end # &bc 'blocks.count:',blocks.count ## add cann key to blocks, calc unmet_dependencies # unmet_dependencies = all_dependency_names.dup blocks = blocks.map do |fcb| - unmet_dependencies.delete(fcb[:nickname] || fcb[:oname]) # may not exist if block name is duplicated + unmet_dependencies.delete(fcb.pub_name) # may not exist if block name is duplicated if (call = fcb[:call]) [get_block_by_anyname("[#{call.match(/^%\((\S+) |\)/)[1]}]") .merge({ cann: call })] else [] @@ -122,11 +119,11 @@ if block_search[:blocks] blocks = collect_wrapped_blocks(block_search[:blocks]) # &bc 'blocks.count:',blocks.count block_search.merge( - { block_names: blocks.map { |block| block[:nickname] || block[:oname] }, + { block_names: blocks.map(&:pub_name), code: blocks.map do |fcb| if fcb[:cann] collect_block_code_cann(fcb) elsif fcb[:stdout] collect_block_code_stdout(fcb) @@ -134,11 +131,11 @@ BlockType::VARS].include? fcb[:shell] nil elsif fcb[:shell] == BlockType::PORT collect_block_code_shell(fcb) elsif label_body - block_name_for_bash_comment = (fcb[:nickname] || fcb[:oname]).gsub(/\s+/, '_') + block_name_for_bash_comment = fcb.pub_name.gsub(/\s+/, '_') [label_format_above && format(label_format_above, block_source.merge({ block_name: block_name_for_bash_comment }))] + fcb[:body] + [label_format_below && format(label_format_below, block_source.merge({ block_name: block_name_for_bash_comment }))] @@ -196,11 +193,11 @@ Filter.fcb_select? options, fcb_title_groups end ### hide rows correctly - if !options[:menu_include_imported_blocks] + unless options[:menu_include_imported_blocks] selrows = selrows.reject do |block| block.fetch(:depth, 0).positive? end end @@ -285,12 +282,10 @@ def recursively_required_hash(source, memo = Hash.new([])) return memo unless source return memo if memo.keys.include? source block = get_block_by_anyname(source) - if block.nil? || block.keys.empty? - raise "Named code block `#{source}` not found. (@#{__LINE__})" - end + raise "Named code block `#{source}` not found. (@#{__LINE__})" if block.nil? || block.keys.empty? memo[source] = block[:reqs] return memo unless memo[source]&.count&.positive? memo[source].each do |req|