text...bify(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

so this is textutil::tabify from the text...bify page, which lives in the Text and string utilities, macro processing part of the manual β€” it's the little package that (un)tabifies your strings, and bestie, it's giving exactly what it says on the tin πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

package require Tcl 8.5 9

package require textutil::tabify ?0.8?

::textutil::tabify::tabify string ?num?

::textutil::tabify::tabify2 string ?num?

::textutil::tabify::untabify string ?num?

::textutil::tabify::untabify2 string ?num?

🌸 DESCRIPTION 🌸

okay so the package textutil::tabify hands you commands that flip back and forth between tabulation and ordinary whitespace inside strings. that's the whole vibe. spaces ↔ tabs, over and over, forever πŸ¦‹

here's the complete set of procedures, no gatekeeping:

  • ::textutil::tabify::tabify string ?num? β€” tabifies string by swapping any substring of num space chars for a tabulation, then hands you the result as a brand-new string. num defaults to 8.
  • ::textutil::tabify::tabify2 string ?num? β€” basically the sibling of ::textutil::tabify: it tabifies the string too and gives you a new string back. BUT. it uses a different algorithm, and that's the whole plot twist 🫢 instead of replacing any substring of num spaces, this one works way more like an editor does. num defaults to 8.

so here's how it thinks: every line of the text in string is treated as if there are tabstops every num columns. only sequences of space characters that have more than one space character AND are found immediately before a tabstop get replaced with tabs. picky queen behavior, honestly ✨

  • ::textutil::tabify::untabify string ?num? β€” untabifies string by replacing any tabulation char with a substring of num space chars, and returns the result as a new string. num defaults to 8.
  • ::textutil::tabify::untabify2 string ?num? β€” untabifies string by replacing any tabulation char with a substring of at most num space chars, and returns the result as a new string. and here's the thing: unlike textutil::tabify::untabify, each tab is not replaced by a fixed number of space characters. nope. instead the command overlays each line in the string with tabstops every num columns, and replaces tabs with just enough space characters to reach the next tabstop. it's literally the complement of what ::textutil::tabify::tabify2 does. num defaults to 8.
there's one asymmetry though, and it's important: a tab can be replaced with a single space, but not the other way around. the pipeline only flows one direction, iykyk 😭

πŸ’€ BUGS, IDEAS, FEEDBACK πŸ’€

ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's giving "we're all human" energy πŸ™ˆ so pls report them in the category textutil of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. and while you're there β€” any ideas for enhancements for either the package and/or the documentation? report those too, we want them fr fr πŸ’–

when you're proposing code changes, pls provide unified diffs, i.e. the output of diff -u.

also note further that attachments are strongly preferred over inlined patches. you make attachments by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. that's the move, no cap πŸ‘‘


🌈 SEE ALSO 🌈


⭐ KEYWORDS ⭐

  • formatting
  • string
  • tabstops

πŸ‘‘ CATEGORY πŸ‘‘

Text processing


and that's the whole page, bestie 🫢 this came from tcllib version 0.8 and it's the text...bify(3tcl) page β€” go forth and tabify responsibly, periodt πŸ’…πŸŒΈ

πŸ“¦ where this page comes from