All doctests in this README have been extracted from the code by Extractly and are therefore tested
-
Make Tag Cloud Styles from a simple DSL
e.g. for HTML
iex(1)> html_style("12 16 100")
~s{style="color: #000000; font-size: 16pt; font-weight: 100;"}
This would then go perfectly into an EEx template
<span <%= tc.html_style("12/peru 2em" %>>
and the CLI will execute an EEx
template with the variable tc
bound to TagCloud
or for an AST like Floki's
or EarmarkParser's
iex(2)> ast_style("12 16 100")
[{"style", "color: #000000; font-size: 16pt; font-weight: 100;"}]
-
Gamma correction for scaled colors
To create 13 different shades of a color, where 0 means transparent (#ffffff) and 12 opaque (original color value or #000000 as default) which are equally spaced for the human eye we use a gamma correction of 1/2.2 which seems to work very well on modern screens.
The result for all 13 shades for some colors can be seen here
Right now the size of the scale and the gamma value cannot be modified but that could be easily implemented if desired.
For gray shades we can indicate the color as an integer
iex(3)> color_value(11)
"525252"
or a string with a default color
iex(4)> color_value("11")
"525252"
or explicitly name the color
iex(5)> color_value("11/black")
"525252"
or use the hex representation
iex(6)> color_value("11/#000000")
"525252"
iex(7)> color_value("10/blue")
"7171ff"
iex(8)> color_value("10/lime")
"71ff71"
iex(9)> color_value("9/fuchsia")
"ff88ff"
iex(10)> color_value("4/medium_slate_blue") # the _ arge ignored
"0d16e0"
iex(11)> color_value("8/DarkGoldenROD") # the color name is downcased
"8d3d89"
But color hex values can be used too
iex(12)> color_value("12/#d2d2d2")
"d2d2d2"
iex(13)> color_value("10/#d2ee0f")
"bee65b"
A convenience method to access this library's version
iex(14)> {:ok, _} = Version.parse(version())
usage:
tag_cloud --help
tag_cloud --version
tag_cloud [ options... <file> ]
convert file from Markdown to HTML.using Earmark and allowing for TagCloud annotations
cond do
file ends with .eex -> treat it as an EEx template
true -> treat file as plain markdown
A convenience method to access this library's version
iex(14)> {:ok, _} = Version.parse(version())
Compiles tag cloud specifications of the form
color font_size font_weight color
to corresponding HTML attributes
Implements the compilation
iex(1)> ast_style("10 12 100")
[{"style", "color: #717171; font-size: 12pt; font-weight: 100;"}]
All 140 color names defined by the CSS standard are supported. The complete list can be found here
iex(2)> ast_style("8/fuchsia 3em 800")
[{"style", "color: #ff9bff; font-size: 3em; font-weight: 800;"}]
iex(3)> ast_style("12/#cafe00")
[{"style", "color: #cafe00;"}]
Copyright © 2021 Robert Dober, robert.dober@gmail.com,
Same as Elixir, which is Apache License v2.0. Please refer to LICENSE for details.