HTML::TagCloud(3pm)
π 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 π
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
- ubuntu noble: libhtml-tagcloud-perl 0.38-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-tagcloud-perl 0.38-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-tagcloud-perl 0.38-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms