antononcube / Raku-Markup-Calendar

Markup (HTML, Markdown) calendar functions for displaying monthly, yearly, and custom calendars.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Markup::Calendar

Raku package with Markup (HTML, Markdown) calendar functions for displaying monthly, yearly, and custom calendars.

Motivation

The package "Text::Calendar", [AAp1], provides the core functions for making the calendars in this package. The packages "Data::Translators", [AAp2], and "Pretty::Table", [ULp1], provide additional formatting functionalities.

I want to keep "Text::Calendar" lightweight, without any dependencies. Hence I made this separate package, "Markup::Calendar", that has more involved dependencies and use-cases.

An "involved use case" is calendar in which some of the days have tooltips and hyperlinks.


Installation

From Zef ecosystem:

zef install Markup::Calendar

From GitHub:

zef install https://github.com/antononcube/Raku-Markup-Calendar.git

Examples

Basic HTML calendar

use Markup::Calendar;
use Text::Calendar;

calendar():html
<style>td { vertical-align: top;a}</style>

January 2024

MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
293031

February 2024

MoTuWeThFrSaSu
1234
567891011
12131415161718
19202122232425
26272829

March 2024

MoTuWeThFrSaSu
123
45678910
11121314151617
18192021222324
25262728293031

HTML yearly calendar with highlights

Here is an HTML calendar that weekend days are highlighted and with larger font:

calendar-year( 
    per-row => 4, 
    highlight => (Date.new(2024,1,1)...Date.new(2024,12,31)).grep({ $_.day-of-week ≥ 6 }),
    highlight-style => 'color:orange; font-size:14pt'
):html

2024

<style>td { vertical-align: top;a}</style>

January

MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
293031

February

MoTuWeThFrSaSu
1234
567891011
12131415161718
19202122232425
26272829

March

MoTuWeThFrSaSu
123
45678910
11121314151617
18192021222324
25262728293031

April

MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
2930

May

MoTuWeThFrSaSu
12345
6789101112
13141516171819
20212223242526
2728293031

June

MoTuWeThFrSaSu
12
3456789
10111213141516
17181920212223
24252627282930

July

MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
293031

August

MoTuWeThFrSaSu
1234
567891011
12131415161718
19202122232425
262728293031

September

MoTuWeThFrSaSu
1
2345678
9101112131415
16171819202122
23242526272829
30

October

MoTuWeThFrSaSu
123456
78910111213
14151617181920
21222324252627
28293031

November

MoTuWeThFrSaSu
123
45678910
11121314151617
18192021222324
252627282930

December

MoTuWeThFrSaSu
1
2345678
9101112131415
16171819202122
23242526272829
3031

Standalone calendar file

Here we make a standalone calendar file:

spurt('example.html', calendar-year(year => 2024, highlight => [3=>3, 5=>24, 9=>9], highlight-style=>'color:red', format=>'html'))
# True

TODO

  • TODO Features
    • DONE HTML
      • DONE Full HTML calendar
      • DONE Partial HTML calendar (e.g. equivalent of cal -3)
      • DONE Highlighted days
      • DONE Tooltips for days
      • DONE Hyperlinks for days
    • TODO Markdown
      • TODO Full Markdown calendar
      • TODO Partial Markdown calendar
      • TODO Highlighted days
      • TODO Tooltips for days
      • TODO Hyperlinks for days
  • Unit tests
    • DONE Basic usage
    • DONE Equivalence using different signatures
    • TODO Correctness
  • Documentation
    • DONE Basic README
    • TODO Diagrams
    • TODO Comparisons

References

[AAp1] Anton Antonov, Text::Calendar Raku package, (2024), GitHub/antononcube.

[AAp2] Anton Antonov, Data::Translators Raku package, (2023), GitHub/antononcube.

[LUp1] Luis F. Uceta, Pretty::Table Raku package, (2020), GitLab/uzluisf.

About

Markup (HTML, Markdown) calendar functions for displaying monthly, yearly, and custom calendars.

License:Artistic License 2.0


Languages

Language:Raku 100.0%