Skip to content

Commit

Permalink
move procedural table to default, include in MD
Browse files Browse the repository at this point in the history
  • Loading branch information
finanalyst committed Jan 7, 2024
1 parent 2eac269 commit 265d5eb
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 233 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-07 v4.10.3
* move procedural table into main default templates from plugin

* modify md templates to correctly output procedural table

# 2024-01-07 v4.10.2
* fix warning in rakudoc-tables when cell empty

Expand Down Expand Up @@ -509,4 +514,4 @@ change testing


----
Rendered from CHANGELOG at 2024-01-07T13:02:22Z
Rendered from CHANGELOG at 2024-01-07T18:40:51Z
15 changes: 3 additions & 12 deletions 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.2",
"version": "4.10.3",
"perl": "6.d",
"authors": [
"Richard Hainsworth"
Expand Down Expand Up @@ -40,7 +40,6 @@
"resources": [
"html-templates-mustache.raku",
"html-templates-crotmp.raku",
"md-templates-mustache.raku",
"html-templates-rakuclosure.raku",
"highlight_files/highlight-filename-from-stdin.coffee",
"highlight_files/package.json",
Expand Down Expand Up @@ -87,15 +86,6 @@
"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 Expand Up @@ -144,7 +134,8 @@
"font-awesome/fonts/fontawesome-webfont.eot",
"font-awesome/font-awesome-4.7.0/less/font-awesome.less",
"font-awesome/font-awesome-4.7.0/less/path.less",
"Samples.rakudoc"
"Samples.rakudoc",
"md-templates-mustache.raku"
],
"support": {
"bugtracker": "https://github.com/finanalyst/raku-pod-render/issues",
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-07 v4.10.3
=item move procedural table into main default templates from plugin
=item modify md templates to correctly output procedural table

=head1 2024-01-07 v4.10.2
=item fix warning in rakudoc-tables when cell empty

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 rakudoc-table>,
:$plugins = <styling simple-extras graphviz latex-render images font-awesome>,
:$add-plugins = '',
:$def-dir
# this option is for testing purposes
Expand Down
60 changes: 45 additions & 15 deletions resources/html-templates-rakuclosure.raku
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,51 @@ use v6;
~ '</section>'
},
'table' => sub ( %prm, %tml ) {
'<table class="pod-table'
~ ( ( %prm<class>:exists and %prm<class> ne '' ) ?? ' ' ~ %tml<escaped>( %prm<class> ) !! '' )
~ '">'
~ ( %prm<caption> ?? ('<caption>' ~ %prm<caption> ~ '</caption>') !! '')
~ ( %prm<headers> ??
("\t<thead>\n"
~ [~] %prm<headers>.map({ "\t\t<tr><th>" ~ .<cells>.join('</th><th>') ~ "</th></tr>\n"})
~ "\t</thead>"
) !! '')
~ "\t<tbody>\n"
~ ( %prm<rows> ??
[~] %prm<rows>.map({ "\t\t<tr><td>" ~ .<cells>.join('</td><td>') ~ "</td></tr>\n" })
!! '')
~ "\t</tbody>\n"
~ "</table>\n"
if %prm<procedural> {
my $rv = "\n<table class=\"table is-bordered centered rakudoc-table pod-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>;
with $cell<data> { $content ~= '">' ~ $cell<data> }
else { $content ~= '">' }
if $cell<header> {
$rv ~= "<th$content\</th>"
}
else {
$rv ~= "<td$content\</td>"
}
}
$rv ~= "</tr>"
}
$rv ~= "</table>\n";
}
else {
'<table class="table is-bordered centered pod-table'
~ ((%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"
}
},
'top-of-page' => sub ( %prm, %tml ) {
if %prm<title-target>:exists and %prm<title-target> ne '' {
Expand Down
43 changes: 28 additions & 15 deletions resources/md-templates-mustache.raku
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,31 @@ use v6;
'para' => '{{{ contents }}}{{> nl2 }}',
'section' => '{{{ contents }}}{{> nl2 }}{{{ tail }}}{{> nl2 }}',
'subtitle' => '>{{{ subtitle }}}{{> nl }}',
'table' => q:to/TEMPL/,
{{# caption }}>{{{ caption }}}{{> nl }}{{/ caption }}
{{# headers }}{{# cells }} | {{{ . }}}{{/ cells }} |
{{# cells }}|:----:{{/ cells}}|
{{/ headers }}
{{# rows }}{{# cells }} | {{{ . }}}{{/ cells }} |{{> nl }}{{/ rows }}
TEMPL
'table' => -> %prm {
if %prm<procedural> {
%prm<grid-headers> = %prm<grid>.shift;
q:to/TEMPL/
{{# grid-headers }}{{# . }}| {{# header }}**{{/ header }}{{{ data }}}{{# header }}**{{/ header }} {{/ . }}{{/ grid-headers }} |
{{# grid-headers }}{{# . }}| --- {{/ . }}{{/ grid-headers }} |
{{# grid }}{{# . }}{{# . }}| {{# no-cell }} - {{/ no-cell }}{{# header }}**{{/ header }}{{# label }}**{{/ label }}{{{ data }}}{{# label }}**{{/ label }}{{# header }}**{{/ header }}{{/ . }}{{/ . }} |
{{/ grid }}
TEMPL
}
else {
q:to/TEMPL/
{{# caption }}>{{{ caption }}}{{> nl }}{{/ caption }}
{{# headers }}{{# cells }} | {{{ . }}}{{/ cells }} |
{{# cells }}|:----:{{/ cells}}|
{{/ headers }}
{{# rows }}{{# cells }} | {{{ . }}}{{/ cells }} |{{> nl }}{{/ rows }}
TEMPL
}
},
'title' => '# {{{ title }}}{{> nl }}',
# templates used by output methods, eg., source-wrap, file-wrap, etc
# In HTML Meta tags can go in the Head section, but for Markdown they will be at the top above the TOC.
'source-wrap' => q:to/TEMPL/,
{{> github_badge }}
# templates used by output methods, eg., source-wrap, file-wrap, etc
# In HTML Meta tags can go in the Head section, but for Markdown they will be at the top above the TOC.
'source-wrap' => q:to/TEMPL/,
{{> github_badge }}
{{> title }}
{{> subtitle }}
{{# metadata }}
Expand All @@ -80,15 +93,15 @@ use v6;
{{> footer }}
TEMPL
'footnotes' => q:to/TEMPL/,
{{# notes }}
{{# notes }}
###### {{ fnNumber }}
{{{ text }}}
{{/ notes }}
TEMPL
'glossary' => '',
'meta' => '{{# meta }}> **{{ name }}** {{ value }}{{> nl2 }}{{/ meta }}',
'toc' => q:to/TEMPL/,
{{# toc }}
'meta' => '{{# meta }}> **{{ name }}** {{ value }}{{> nl2 }}{{/ meta }}',
'toc' => q:to/TEMPL/,
{{# toc }}
[{{ text }}](#{{ target }}){{> sp2 }}
{{/ toc }}
TEMPL
Expand Down
6 changes: 0 additions & 6 deletions resources/rakudoc-table/README.rakudoc

This file was deleted.

13 changes: 0 additions & 13 deletions resources/rakudoc-table/config.raku

This file was deleted.

28 changes: 0 additions & 28 deletions resources/rakudoc-table/css/rakudoc-table-dark.css

This file was deleted.

28 changes: 0 additions & 28 deletions resources/rakudoc-table/css/rakudoc-table-light.css

This file was deleted.

51 changes: 0 additions & 51 deletions resources/rakudoc-table/rakudoc-table-templates.raku

This file was deleted.

29 changes: 0 additions & 29 deletions resources/rakudoc-table/scss/_rakudoc-table.scss

This file was deleted.

Loading

0 comments on commit 265d5eb

Please sign in to comment.