lib/mdoc.rb in markdown_exec-2.2.0 vs lib/mdoc.rb in markdown_exec-2.3.0
- old
+ new
@@ -85,23 +85,25 @@
dependencies = collect_dependencies(nickname)
# &bt dependencies.count
all_dependency_names = collect_unique_names(dependencies).push(nickname).uniq
# &bt all_dependency_names.count
- # select non-chrome blocks in order of appearance in source documents
+ # select blocks in order of appearance in source documents
#
blocks = @table.select do |fcb|
- # !fcb.fetch(:chrome, false) && all_dependency_names.include?(fcb.pub_name)
- all_dependency_names.include?(fcb.pub_name)
+ # 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
## add cann key to blocks, calc unmet_dependencies
#
unmet_dependencies = all_dependency_names.dup
blocks = blocks.map do |fcb|
- unmet_dependencies.delete(fcb.pub_name) # may not exist if block name is duplicated
+ # 2024-08-04 match oname for long block names
+ # 2024-08-04 match nickname
+ unmet_dependencies.delete(fcb.pub_name) || unmet_dependencies.delete(fcb.nickname) || unmet_dependencies.delete(fcb.oname) # may not exist if block name is duplicated
if (call = fcb.call)
[get_block_by_anyname("[#{call.match(/^%\((\S+) |\)/)[1]}]")
.merge({ cann: call })]
else
[]
@@ -260,11 +262,12 @@
# If `fcb.pub_name` returns "Example Block", `fcb.body` returns ["line1", "line2"],
# `block_source` is { source: "source_info" }, `label_format_above` is "Start of %{block_name}",
# and `label_format_below` is "End of %{block_name}", the method will return:
# ["Start of Example_Block", "line1", "line2", "End of Example_Block"]
#
- def generate_label_body_code(fcb, block_source, label_format_above, label_format_below)
+ def generate_label_body_code(fcb, block_source, label_format_above,
+ label_format_below)
block_name_for_bash_comment = fcb.pub_name.gsub(/\s+/, '_')
label_above = if label_format_above
format(label_format_above,
block_source.merge({ block_name: block_name_for_bash_comment }))
@@ -385,11 +388,13 @@
return memo unless block.reqs
memo[source] = block.reqs
- block.reqs.each { |req| collect_dependencies(req, memo) unless memo.key?(req) }
+ block.reqs.each do |req|
+ collect_dependencies(req, memo) unless memo.key?(req)
+ end
memo
end
def select_elements_with_neighbor_conditions(array,
last_selected_placeholder = nil, next_selected_placeholder = nil)
@@ -454,10 +459,12 @@
assert_empty @mdoc.collect_dependencies(nil)
end
if false # must raise error
def test_collect_dependencies_with_nonexistent_source
- assert_raises(RuntimeError) { @mdoc.collect_dependencies('nonexistent') }
+ assert_raises(RuntimeError) do
+ @mdoc.collect_dependencies('nonexistent')
+ end
end
end
def test_collect_dependencies_with_valid_source
@mdoc.stubs(:get_block_by_anyname).with('source1').returns({ reqs: ['source2'] })