View/Edit #52:add_tag

Switch to edit mode.

Name(s): add_tag
1:  "Put the text between a set of HTML tags."
2:  ":add_tag('hello', 'B') => '<B>hello</B>'"
3:  ":add_tag({'line 1', 'line 2'}, 'TEXTAREA COLS=70') => "
4:  "  {'<TEXTAREA COLS=70>line 1', 'line 2</TEXTAREA>'}"
5:  {text, tag} = args
6:  opentag = "<" + tag + ">"
7:  closetag = "</" + tag[1..(index(tag, " ") || $ + 1) - 1] + ">"
8:  if (typeof(text) == $LIST)
9:    text = {opentag, @text, closetag}
10:   text[$ - 1..$] = {tostr(text[$ - 1], text[$])}
11:   if (length(text) > 1)
12:     text[1..2] = {tostr(text[1], text[2])}
13:   endif
14:   return text
15: else
16:   return tostr(opentag, text, closetag)
17: endif
18: "Last modified by Dax (#789) on Tue May  3 13:45:02 2005 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Hacker (#60)

You are not logged in.

[home | help | who | search | setup | code]