HTML::TagCloud(3pm)

πŸ“¦
version 0.38 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– HTML::TagCloud β€” Generate An HTML Tag Cloud πŸ’–

okay bestie, this is HTML::TagCloud from the Perl docs (the "User Contributed Perl Documentation" section, if you're keeping track 🫢). Basically: it makes tag clouds. In HTML. And it's lowkey iconic.


✨ SYNOPSIS ✨

# A cloud with tags that link to other web pages.
my $cloud = HTML::TagCloud->new;
$cloud->add($tag1, $url1, $count1);
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);
my $html = $cloud->html_and_css(50);

# A cloud with tags that do not link to other web pages.
my $cloud = HTML::TagCloud->new;
$cloud->add_static($tag1, $count1);
$cloud->add_static($tag2, $count2);
$cloud->add_static($tag3, $count3);
my $html = $cloud->html_and_css(50);

# A cloud that is comprised of tags in multiple categories.
my $cloud = HTML::TagCloud->new;
$cloud->add($tag1, $url1, $count1, $category1);
$cloud->add($tag2, $url2, $count2, $category2);
$cloud->add($tag3, $url3, $count3, $category3);
my $html = $cloud->html_and_css(50);

# The same cloud without tags that link to other web pages.
my $cloud = HTML::TagCloud->new;
$cloud->add_static($tag1, $count1, $category1);
$cloud->add_static($tag2, $count2, $category2);
$cloud->add_static($tag3, $count3, $category3);
my $html = $cloud->html_and_css(50);

# Obtaining uncategorized HTML for a categorized tag cloud.
my $html = $cloud->html_without_categories();

# Explicitly requesting categorized HTML.
my $html = $cloud->html_with_categories();

🌸 DESCRIPTION 🌸

So HTML::TagCloud lets you generate "tag clouds" in HTML. A tag cloud is like the textual way to visualize which terms and topics get used the most. The tags get sorted alphabetically, and the more a term is used, the bigger the font gets. It's giving data viz but make it cute. πŸ“Šβœ¨

Some example sites that have tag clouds (iykyk): <http://www.43things.com/>, <http://www.astray.com/recipes/> and <http://www.flickr.com/photos/tags/>.

This module gives you a super simple interface for generating a CSS-based HTML tag cloud. You literally just pass in a set of tags, their URL, and their count. And it outputs stylesheet-based HTML. You can use the included CSS, or you can bring your own. Your call, bestie. πŸ’…


πŸ‘‘ CONSTRUCTOR πŸ‘‘

⭐ new

The constructor takes a few optional arguments, no pressure:

my $cloud = HTML::TagCloud->new(levels=>10);

and if you don't provide levels, it defaults to 24. Yes, 24, no cap.

my $cloud = HTML::TagCloud->new(distinguish_adjacent_tags=>1);

If distinguish_adjacent_tags is true, then HTML::TagCloud will use different CSS classes for adjacent tags, so it's easier to tell adjacent multi-word tags apart. And if you don't specify it at all? This parameter defaults to a false value. fr fr.

my $cloud = HTML::TagCloud->new(categories=>\@categories);

If categories are provided, then the tags get grouped into separate divisions by category when the HTML fragment is generated. Organized queen behavior. πŸŽ€


πŸ¦‹ METHODS πŸ¦‹

πŸ’œ add

This adds a tag into the cloud. You pass in the tag name, its URL and its count:

$cloud->add($tag1, $url1, $count1);
$cloud->add($tag2, $url2, $count2);
$cloud->add($tag3, $url3, $count3);

πŸ’œ add_static

This adds a tag that does not link to another web page into the cloud. You pass in the tag name and its count:

$cloud->add_static($tag1, $count1);
$cloud->add_static($tag2, $count2);

πŸ’œ tags($limit)

Returns a list of hashrefs representing each tag in the cloud, sorted by alphabet. Each tag has the following keys: name, count, url and level.

πŸ’œ css

This returns the CSS that will format the HTML returned by the html() method, with tags that have a high count shown as larger:

my $css  = $cloud->css;

πŸ’œ html($limit)

This returns the tag cloud as HTML without the embedded CSS (you should use both css() and html(), or just the html_and_css() method, bestie, don't do it halfway 🌈). If any categories were specified when the items were being placed in the cloud, then the tags get organized into divisions by category name. And if a limit is provided, only the top $limit tags are in the cloud β€” otherwise all the tags are in the cloud:

my $html = $cloud->html(200);

πŸ’œ html_with_categories($limit)

This returns the tag cloud as HTML without the embedded CSS. The tags will be arranged into divisions by category. If a limit is provided, only the top $limit tags are in the cloud. Otherwise, all tags are in the cloud.

πŸ’œ html_without_categories($limit)

This returns the tag cloud as HTML without the embedded CSS. The tags will not be grouped by category if this method is used to generate the HTML.

πŸ’œ html_and_css($limit)

This returns the tag cloud as HTML with embedded CSS. If a limit is provided, only the top $limit tags are in the cloud β€” otherwise all the tags are in the cloud:

my $html_and_css = $cloud->html_and_css(50);

🌈 AUTHOR 🌈

Leon Brocard, "<acme@astray.com>". πŸ’–


Copyright (C) 2005-6, Leon Brocard

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.


okay so that's the whole thing, no notes, you got this bestie πŸ’…βœ¨

and a lil sign-off for the girlies keeping receipts: this was perl v5.36.0, dated 2022-10-13, and it's HTML::TagCloud(3pm). mwah 🫢🌸

πŸ“¦ where this page comes from