30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/markdown_composer/transform_options.rb', line 30
def optional(transform, mode, adapter_option_keys: [])
base = case [ transform.to_s, mode.to_s ]
when [ "heading_numbers", "keep" ] then %w[levels format]
when [ "heading_numbers", "strip" ] then %w[levels pattern]
when [ "heading_numbers", "add" ] then %w[start format skip_if_present]
when [ "heading_numbers", "rebuild" ] then %w[start format exclude restart_at]
when [ "replace_text", "literal" ] then %w[case_sensitive limit whole_node]
when [ "replace_text", "word" ] then %w[case_sensitive limit]
when [ "replace_text", "regex" ] then %w[case_sensitive limit]
when [ "links", "keep" ] then []
when [ "links", "unwrap" ] then %w[keep_text]
when [ "links", "remove" ] then %w[keep_text]
when [ "links", "rewrite_url" ] then %w[match case_sensitive]
when [ "links", "nofollow" ], [ "links", "target_blank" ] then []
when [ "heading_levels", "promote" ], [ "heading_levels", "demote" ] then %w[min_level max_level]
when [ "heading_levels", "normalise" ] then []
when [ "remove_empty", "remove" ] then %w[trim ignore_nbsp ignore_comments]
when [ "insert_before", "insert" ], [ "insert_after", "insert" ] then %w[dedupe parse_as]
when [ "prepend_content", "insert" ], [ "append_content", "insert" ] then %w[target dedupe parse_as]
when [ "replace_content", "replace" ] then %w[parse_as]
when [ "remove_content", "remove" ] then []
when [ "dedupe", "normalised_text" ] then %w[case_sensitive]
when [ "dedupe", "source_node_id" ] then []
when [ "order", "action_order" ], [ "order", "source_order" ] then []
when [ "order", "target_order" ] then []
when [ "sanitise", "block_safe" ], [ "sanitise", "text_only" ], [ "sanitise", "links_unwrapped" ], [ "sanitise", "strict" ] then %w[profile]
else
%w[levels from to by unit profile name content as target parse_as case_sensitive limit dedupe format pattern start skip_if_present exclude restart_at keep_text match min_level max_level trim ignore_nbsp ignore_comments whole_node]
end
transform.to_s == "adapter" ? base + Array(adapter_option_keys).map(&:to_s) : base
end
|