markdown_exec 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +2 -2
- data/Rakefile +3 -3
- data/bats/block-types.bats +13 -7
- data/bats/import.bats +6 -0
- data/bats/markup.bats +6 -15
- data/bats/options-collapse.bats +26 -0
- data/bats/options.bats +1 -1
- data/bats/table.bats +8 -0
- data/bats/test_helper.bash +74 -49
- data/bats/variable-expansion.bats +46 -0
- data/bin/tab_completion.sh +1 -1
- data/docs/dev/bats-document-configuration.md +8 -1
- data/docs/dev/block-type-bash.md +1 -1
- data/docs/dev/block-type-opts.md +1 -5
- data/docs/dev/block-type-vars.md +4 -0
- data/docs/dev/import-missing.md +2 -0
- data/docs/dev/menu-cli.md +1 -1
- data/docs/dev/options-collapse.md +47 -0
- data/docs/dev/requiring-blocks.md +3 -0
- data/docs/dev/specs.md +2 -1
- data/docs/dev/table-crash.md +39 -0
- data/docs/dev/table-indent.md +26 -0
- data/docs/dev/text-decoration.md +2 -5
- data/docs/dev/variable-expansion.md +2 -4
- data/examples/bash-blocks.md +1 -1
- data/examples/block-names.md +1 -1
- data/examples/block-types.md +1 -1
- data/examples/data-files.md +1 -1
- data/examples/document_options.md +2 -2
- data/examples/indent.md +1 -1
- data/examples/interrupt.md +1 -1
- data/examples/link-blocks-vars.md +1 -1
- data/examples/linked.md +1 -1
- data/examples/linked1.md +1 -1
- data/examples/nickname.md +1 -1
- data/examples/opts-blocks-require.md +1 -1
- data/examples/opts-blocks.md +1 -1
- data/examples/opts_output_execution.md +1 -1
- data/examples/pass-through-arguments.md +1 -1
- data/examples/pause-after-execution.md +1 -1
- data/examples/port-blocks.md +1 -1
- data/examples/save.md +1 -1
- data/examples/text-markup.md +1 -1
- data/examples/variable-expansion.md +6 -2
- data/examples/vars-blocks.md +1 -1
- data/examples/wrap.md +1 -1
- data/lib/block_types.rb +4 -0
- data/lib/cached_nested_file_reader.rb +7 -4
- data/lib/collapser.rb +302 -0
- data/lib/constants.rb +10 -0
- data/lib/evaluate_shell_expressions.rb +0 -3
- data/lib/fcb.rb +13 -17
- data/lib/format_table.rb +11 -7
- data/lib/hash_delegator.rb +461 -272
- data/lib/hierarchy_string.rb +5 -1
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +16 -32
- data/lib/mdoc.rb +100 -35
- data/lib/menu.src.yml +124 -17
- data/lib/menu.yml +102 -16
- data/lib/ww.rb +75 -22
- metadata +12 -9
- data/lib/append_to_bash_history.rb +0 -303
- data/lib/ce_get_cost_and_usage.rb +0 -23
- data/lib/doh.rb +0 -190
- data/lib/layered_hash.rb +0 -143
- data/lib/poly.rb +0 -171
data/lib/fcb.rb
CHANGED
@@ -64,7 +64,8 @@ module MarkdownExec
|
|
64
64
|
def for_menu!(
|
65
65
|
block_calls_scan: @delegate_object[:block_calls_scan],
|
66
66
|
block_name_match: @delegate_object[:block_name_match],
|
67
|
-
block_name_nick_match: @delegate_object[:block_name_nick_match]
|
67
|
+
block_name_nick_match: @delegate_object[:block_name_nick_match],
|
68
|
+
id: ''
|
68
69
|
)
|
69
70
|
call = @attrs[:call] = @attrs[:start_line]&.match(
|
70
71
|
Regexp.new(block_calls_scan)
|
@@ -83,7 +84,7 @@ module MarkdownExec
|
|
83
84
|
bm && bm[1] ? bm[:title] : titlexcall
|
84
85
|
end
|
85
86
|
@attrs[:title] = @attrs[:oname] = oname
|
86
|
-
|
87
|
+
@attrs[:id] = id
|
87
88
|
@attrs[:dname] = HashDelegator.indent_all_lines(
|
88
89
|
(yield oname, BLOCK_TYPE_COLOR_OPTIONS[@attrs[:type]]),
|
89
90
|
@attrs[:indent]
|
@@ -107,17 +108,10 @@ module MarkdownExec
|
|
107
108
|
def method_missing(method, *args, &block)
|
108
109
|
method_name = method.to_s
|
109
110
|
if @attrs.respond_to?(method_name)
|
110
|
-
if method_name == 'fetch'
|
111
|
-
ww args[0]
|
112
|
-
end
|
113
111
|
@attrs.send(method_name, *args, &block)
|
114
112
|
elsif method_name[-1] == '='
|
115
|
-
# ww caller.take(3) if method_name == 'label='
|
116
|
-
ww method_name
|
117
113
|
@attrs[method_name.chop.to_sym] = args[0]
|
118
114
|
else
|
119
|
-
# ww caller.take(3) if method_name == 'label'
|
120
|
-
ww method_name
|
121
115
|
@attrs[method_name.to_sym]
|
122
116
|
end
|
123
117
|
rescue StandardError => err
|
@@ -158,20 +152,22 @@ ww method_name
|
|
158
152
|
@attrs.to_yaml
|
159
153
|
end
|
160
154
|
|
161
|
-
# Expand in
|
162
|
-
def
|
155
|
+
# Expand variables in `dname` and `body` attributes
|
156
|
+
def expand_variables_in_attributes!(pattern, replacements)
|
163
157
|
### update name, nickname, title, label ???
|
164
|
-
|
165
|
-
|
166
|
-
|
158
|
+
|
159
|
+
# Replace variables in `dname` using the replacements dictionary
|
160
|
+
@attrs[:dname] = @attrs[:dname].gsub(pattern) do |match|
|
161
|
+
replacements[match]
|
162
|
+
end
|
163
|
+
|
164
|
+
# Replace variables in each line of `body` if `body` is present
|
167
165
|
if @attrs[:body]
|
168
166
|
@attrs[:body] = @attrs[:body].map do |line|
|
169
167
|
if line.empty?
|
170
168
|
line
|
171
169
|
else
|
172
|
-
line.gsub(pattern)
|
173
|
-
replacement_dictionary[match]
|
174
|
-
end
|
170
|
+
line.gsub(pattern) { |match| replacements[match] }
|
175
171
|
end
|
176
172
|
end
|
177
173
|
end
|
data/lib/format_table.rb
CHANGED
@@ -74,11 +74,11 @@ module MarkdownTableFormatter
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
def
|
77
|
+
def format_row_line__hs(
|
78
78
|
row, alignment_indicators, column_widths, decorate,
|
79
79
|
text_sym: :text, style_sym: :color
|
80
80
|
)
|
81
|
-
return
|
81
|
+
return HierarchyString.new if row.cells.nil?
|
82
82
|
|
83
83
|
border_style = decorate && decorate[:border]
|
84
84
|
HierarchyString.new(
|
@@ -103,16 +103,20 @@ module MarkdownTableFormatter
|
|
103
103
|
{ text_sym => ' |', style_sym => border_style }].compact,
|
104
104
|
style_sym: style_sym,
|
105
105
|
text_sym: text_sym
|
106
|
-
)
|
106
|
+
)
|
107
107
|
end
|
108
108
|
|
109
|
-
def
|
109
|
+
def format_rows__hs(rows, alignment_indicators, column_widths, decorate)
|
110
110
|
rows.map do |row|
|
111
|
-
|
111
|
+
format_row_line__hs(row, alignment_indicators, column_widths, decorate)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
def format_table(
|
115
|
+
def format_table(**kwargs)
|
116
|
+
format_table__hs(**kwargs).map(&:decorate)
|
117
|
+
end
|
118
|
+
|
119
|
+
def format_table__hs(lines:, column_count:, decorate: nil)
|
116
120
|
unless column_count.positive?
|
117
121
|
return lines.map do |line|
|
118
122
|
HierarchyString.new([{ text: line }])
|
@@ -125,7 +129,7 @@ module MarkdownTableFormatter
|
|
125
129
|
alignment_indicators, column_widths =
|
126
130
|
calculate_column_alignment_and_widths(rows, column_count)
|
127
131
|
|
128
|
-
|
132
|
+
format_rows__hs(rows, alignment_indicators, column_widths, decorate)
|
129
133
|
end
|
130
134
|
|
131
135
|
def insert_every_other(array, obj)
|