All doctests in this README have been extracted from the code by Extractly and are therefore tested

TagCloud

CI Coverage Status Hex.pm Hex.pm Hex.pm

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;"}]
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"

TagCloud.version/0

A convenience method to access this library's version

iex(14)> {:ok, _} = Version.parse(version())

TagCloud.Cli

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

TagCloud.version/0

A convenience method to access this library's version

iex(14)> {:ok, _} = Version.parse(version())

TagCloud.Compiler

Compiles tag cloud specifications of the form color font_size font_weight color to corresponding HTML attributes

TagCloud.Compiler.ast_style/1

Implements the compilation

Gray Scale

iex(1)> ast_style("10 12 100")
[{"style", "color: #717171; font-size: 12pt; font-weight: 100;"}]

Scale on Predefined Colors

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;"}]

Just use your own color

iex(3)> ast_style("12/#cafe00")
[{"style", "color: #cafe00;"}]

Author

Copyright © 2021 Robert Dober, robert.dober@gmail.com,

LICENSE

Same as Elixir, which is Apache License v2.0. Please refer to LICENSE for details.