lib/mdoc.rb in markdown_exec-2.4.0 vs lib/mdoc.rb in markdown_exec-2.5.0
- old
+ new
@@ -23,11 +23,11 @@
#
# @param table [Array<Hash>] An array of hashes representing markdown sections.
#
def initialize(table = [])
@table = table
- # &bt @table.count
+ # !!t @table.count
end
def collect_block_code_cann(fcb)
body = fcb.body.join("\n")
xcall = fcb[:cann][1..-2]
@@ -81,21 +81,21 @@
end
nickname = name_block.pub_name
dependencies = collect_dependencies(nickname)
- # &bt dependencies.count
+ # !!t dependencies.count
all_dependency_names = collect_unique_names(dependencies).push(nickname).uniq
- # &bt all_dependency_names.count
+ # !!t all_dependency_names.count
# select blocks in order of appearance in source documents
#
blocks = @table.select do |fcb|
# 2024-08-04 match nickname
all_dependency_names.include?(fcb.pub_name) || all_dependency_names.include?(fcb.nickname) || all_dependency_names.include?(fcb.oname)
end
- # &bt blocks.count
+ # !!t blocks.count
## add cann key to blocks, calc unmet_dependencies
#
unmet_dependencies = all_dependency_names.dup
blocks = blocks.map do |fcb|
@@ -108,11 +108,11 @@
[fcb1]
else
[]
end + [fcb]
end.flatten(1)
- # &bt unmet_dependencies.count
+ # !!t unmet_dependencies.count
{ all_dependency_names: all_dependency_names,
blocks: blocks,
dependencies: dependencies,
unmet_dependencies: unmet_dependencies }
@@ -126,27 +126,28 @@
def collect_recursively_required_code(anyname:, block_source:, label_body: true, label_format_above: nil,
label_format_below: nil)
block_search = collect_block_dependencies(anyname: anyname)
if block_search[:blocks]
blocks = collect_wrapped_blocks(block_search[:blocks])
- # &bt blocks.count
+ # !!t blocks.count
block_search.merge(
{ 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)
- elsif [BlockType::OPTS].include? fcb.shell
+ elsif [BlockType::OPTS].include? fcb.type
fcb.body # entire body is returned to requesing block
elsif [BlockType::LINK,
- BlockType::VARS].include? fcb.shell
+ BlockType::LOAD,
+ BlockType::VARS].include? fcb.type
nil
elsif fcb[:chrome] # for Link blocks like History
nil
- elsif fcb.shell == BlockType::PORT
+ elsif fcb.type == BlockType::PORT
generate_env_variable_shell_commands(fcb)
elsif label_body
generate_label_body_code(fcb, block_source, label_format_above,
label_format_below)
else # raw body
@@ -290,17 +291,16 @@
# @param name [String] The name of the code block to retrieve.
# @param default [Hash] The default value to return if the code block is not found.
# @return [Hash] The code block as a hash or the default value if not found.
#
def get_block_by_anyname(name, default = {})
- # &bt name
+ # !!t name
@table.select do |fcb|
- fcb.tap { |_ret| pp [__LINE__, 'get_block_by_anyname()', 'fcb', fcb] if $pd }
fcb.nickname == name ||
fcb.dname == name ||
fcb.oname == name ||
fcb.pub_name == name
- end.fetch(0, default).tap { |ret| pp [__LINE__, 'get_block_by_anyname() ->', ret] if $pd }
+ end.fetch(0, default)
end
# Checks if a code block should be hidden based on the given options.
#
# @param opts [Hash] The options used for hiding code blocks.