Skip to content

Commit

Permalink
add rakudoc-table plugin to render procedural tables
Browse files Browse the repository at this point in the history
  • Loading branch information
finanalyst committed Jan 4, 2024
1 parent 6d5453a commit c06cca1
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
>Change log

# 2024-01-04 v4.10.1
* add rakudoc-table to plugins

* the plugin adds procedural tables as defined in RakuDoc v2 to HTML2 only

# 2023-12-22 v4.10.0
* modify rewrite-target to produce Raku/doc markup targets

Expand Down Expand Up @@ -501,4 +506,4 @@ change testing


----
Rendered from CHANGELOG at 2023-12-22T14:10:17Z
Rendered from CHANGELOG at 2024-01-04T23:40:02Z
11 changes: 10 additions & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Raku::Pod::Render",
"description": "A generic Pod6 Renderer with custom Pod::Blocks, FormatCodes for one or more files using templates, provides HTML and MarkDown.",
"version": "4.10.0",
"version": "4.10.1",
"perl": "6.d",
"authors": [
"Richard Hainsworth"
Expand Down Expand Up @@ -87,6 +87,15 @@
"move-assets/cleanup.raku",
"move-assets/templates.raku",
"move-assets/README.rakudoc",
"rakudoc-table/config.raku",
"rakudoc-table/rakudoc-table-templates.raku",
"rakudoc-table/README.rakudoc",
"rakudoc-table/css/rakudoc-table-dark.css",
"rakudoc-table/css/rakudoc-table-light.css",
"rakudoc-table/scss/rakudoc-table-dark.scss",
"rakudoc-table/scss/rakudoc-table-light.scss",
"rakudoc-table/scss/_rakudoc-table.scss",
"rakudoc-table/scss/_themes-colors.scss",
"styling/config.raku",
"styling/_highlights.scss",
"styling/rakudoc-styling.scss",
Expand Down
4 changes: 4 additions & 0 deletions doc/CHANGELOG.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
=TITLE Raku::Pod::Render
=SUBTITLE Change log

=head1 2024-01-04 v4.10.1
=item add rakudoc-table to plugins
=item2 the plugin adds procedural tables as defined in RakuDoc v2 to HTML2 only

=head1 2023-12-22 v4.10.0
=item modify rewrite-target to produce Raku/doc X<> markup targets
=item2 Raku has `X<text|Head,item;Head2,item>` type markup
Expand Down
2 changes: 1 addition & 1 deletion lib/Pod/To/HTML2.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Pod::To::HTML2 is ProcessedPod {
submethod TWEAK(
:$highlight-code,
:$type = 'rakuclosure',
:$plugins = <styling simple-extras graphviz latex-render images font-awesome>,
:$plugins = <styling simple-extras graphviz latex-render images font-awesome rakudoc-table>,
:$add-plugins = '',
:$def-dir
# this option is for testing purposes
Expand Down
1 change: 1 addition & 0 deletions lib/Pod/To/MarkDown2.rakumod
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ProcessedPod;
use RenderPod::Exceptions;
use JSON::Fast;

unit class Pod::To::MarkDown2 is ProcessedPod;
has $.def-ext is rw;
Expand Down
6 changes: 6 additions & 0 deletions resources/rakudoc-table/README.rakudoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=begin pod
=TITLE grid-block is a plugin for Collection

The plugin is to render the enhanced C<=table> block

=end pod
13 changes: 13 additions & 0 deletions resources/rakudoc-table/config.raku
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%(
:auth<collection>,
:authors(
"finanalyst",
),
:custom-raku(),
:license<Artistic-2.0>,
:name<rakudoc-table>,
:render,
:css<css/rakudoc-table-light.css>,
:template-raku<rakudoc-table-templates.raku>,
:version<0.1.2>,
)
28 changes: 28 additions & 0 deletions resources/rakudoc-table/css/rakudoc-table-dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Basic code colors */
.rakudoc-table .rakudoc-cell-center, .rakudoc-table .rakudoc-cell-centre {
text-align: center;
}
.rakudoc-table .rakudoc-cell-left {
text-align: left;
}
.rakudoc-table .rakudoc-cell-right {
text-align: right;
}
.rakudoc-table .rakudoc-cell-top {
vertical-align: top;
}
.rakudoc-table .rakudoc-cell-bottom {
vertical-align: bottom;
}
.rakudoc-table .rakudoc-cell-middle {
vertical-align: middle;
}
.rakudoc-table .rakudoc-cell-label {
text-align: left;
vertical-align: middle;
font-weight: 600;
}
.rakudoc-table.table tbody th {
text-align: center;
vertical-align: middle;
}
28 changes: 28 additions & 0 deletions resources/rakudoc-table/css/rakudoc-table-light.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Basic code colors */
.rakudoc-table .rakudoc-cell-center, .rakudoc-table .rakudoc-cell-centre {
text-align: center;
}
.rakudoc-table .rakudoc-cell-left {
text-align: left;
}
.rakudoc-table .rakudoc-cell-right {
text-align: right;
}
.rakudoc-table .rakudoc-cell-top {
vertical-align: top;
}
.rakudoc-table .rakudoc-cell-bottom {
vertical-align: bottom;
}
.rakudoc-table .rakudoc-cell-middle {
vertical-align: middle;
}
.rakudoc-table .rakudoc-cell-label {
text-align: left;
vertical-align: middle;
font-weight: 600;
}
.rakudoc-table.table tbody th {
text-align: center;
vertical-align: middle;
}
50 changes: 50 additions & 0 deletions resources/rakudoc-table/rakudoc-table-templates.raku
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env raku
use v6.d;
%(
'table' => sub (%prm, %tml) {
if %prm<procedural> {
my $rv = "\n<table class=\"table is-bordered centered rakudoc-table { %prm<class> // '' }\">";
$rv ~= "\n<caption>$_\</caption>" with %prm<caption>;
for %prm<grid>.list -> @row {
$rv ~= "\n<tr>";
for @row -> $cell {
next if $cell<no-cell>;
my $content;
$content ~= ' colspan="' ~ $cell<span>[0] ~'"' if $cell<span>:exists and $cell<span>[0] != 1;
$content ~= ' rowspan="' ~ $cell<span>[1] ~'"' if $cell<span>:exists and $cell<span>[1] != 1;
$content ~= ' class="';
with $cell<align> { for .list {
$content ~= "rakudoc-cell-$_ "
} }
$content ~= 'rakudoc-cell-label' if $cell<label>;
$content ~= '">' ~ $cell<data>;
if $cell<header> {
$rv ~= "<th$content\</th>"
}
else {
$rv ~= "<td$content\</td>"
}
}
$rv ~= "</tr>"
}
$rv ~= "</table>\n";
}
else {
'<table class="table is-bordered centered'
~ ((%prm<class>.defined and %prm<class> ne '') ?? (' ' ~ %tml<escaped>.(%prm<class>)) !! '')
~ '">'
~ ((%prm<caption>.defined and %prm<caption> ne '') ?? ('<caption>' ~ %prm<caption> ~ '</caption>') !! '')
~ ((%prm<headers>.defined and %prm<headers> ne '') ??
("\t<thead>\n"
~ [~] %prm<headers>.map({ "\t\t<tr><th>" ~ .<cells>.join('</th><th>') ~ "</th></tr>\n" })
~ "\t</thead>"
) !! '')
~ "\t<tbody>\n"
~ ((%prm<rows>.defined and %prm<rows> ne '') ??
[~] %prm<rows>.map({ "\t\t<tr><td>" ~ .<cells>.join('</td><td>') ~ "</td></tr>\n" })
!! '')
~ "\t</tbody>\n"
~ "</table>\n"
}
},
)
29 changes: 29 additions & 0 deletions resources/rakudoc-table/scss/_rakudoc-table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.rakudoc-table {
.rakudoc-cell-center, .rakudoc-cell-centre {
text-align: center;
}
.rakudoc-cell-left {
text-align: left;
}
.rakudoc-cell-right {
text-align: right;
}
.rakudoc-cell-top {
vertical-align: top;
}
.rakudoc-cell-bottom {
vertical-align: bottom;
}
.rakudoc-cell-middle {
vertical-align: middle;
}
.rakudoc-cell-label {
text-align: left;
vertical-align: middle;
font-weight: 600;
}
&.table tbody th {
text-align: center;
vertical-align: middle;
}
}
25 changes: 25 additions & 0 deletions resources/rakudoc-table/scss/_themes-colors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Common theme colors

$black: #030303;
$black-bis: #1B1D1E;
$black-ter: #212426;

$grey-darker: #3A3D4E;
$grey-dark: #83858D;
$grey: #cccccc;
$grey-light: #d8d8d8;
$grey-lighter: #e5e5e5;
$grey-lightest: #f2f2f2;

$white-ter: #f5f5f5;
$white-bis: #f7f7f7;
$white: #fafafa;

$orange: hsl(14, 100%, 53%);
$yellow: #EED891;
$green: #1C6301;
$turquoise: #005C43;
$cyan: hsl(204, 71%, 53%);
$blue: #004FB3;
$purple: #5503B3;
$red: #A30031;
5 changes: 5 additions & 0 deletions resources/rakudoc-table/scss/rakudoc-table-dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Basic code colors */
@import '_themes-colors.scss';


@import '_rakudoc-table.scss';
4 changes: 4 additions & 0 deletions resources/rakudoc-table/scss/rakudoc-table-light.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Basic code colors */
@import '_themes-colors.scss';

@import '_rakudoc-table.scss';

0 comments on commit c06cca1

Please sign in to comment.