Function: tag_contents

Function: tag_contents

Usage

 tag_contents(tag: some_tag, contents: some_function, some_string)

Apply a function to the contents of a particular tag. The function is called with input set to the old value inside the tag.

The tag can be a whole tag, "<tag>", or a prefix "<i". In the latter case all tags starting with "<i" are removed.

Parameters

Parameter Type Description
tag string Tag to match
contents function Function to apply to the contents
input tagged string String to change

Examples

 tag_contents(tag: "<up>", contents: to_upper, "this <up>is text</up>")
     ==  "this <up>IS TEXT</up>"
 tag_contents(tag: "<atom-name", contents: { card.name }, "<atom-name-auto></atom-name-auto> loses 1 life")
   ==  "<atom-name-auto>Pink Elephant</atom-name-auto> loses 1 life"

 f := tag_contents@(tag: "<i>", contents: {""})
 f("text, <i-auto>reminder</i-auto> <i>italic</i>") == "text, <i-auto>reminder</i-auto> <i></i>"

See also

remove_tag Remove a tag, keep the contents.