Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add --no-highlight option to htmlify
Which passes information about whether or not to run syntax highlighting on
to the website object which builds the website.
  • Loading branch information
Paul Cochrane committed Aug 27, 2015
1 parent a39a3a6 commit 8a9c60d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 63 deletions.
128 changes: 66 additions & 62 deletions htmlify.pl
Expand Up @@ -4,74 +4,78 @@
use Pod::Htmlify;
use Perl6::Examples;

my %base-categories-table =
"best-of-rosettacode" => "Best of Rosettacode",
"99-problems" => "99 problems",
"cookbook" => "Cookbook examples",
"euler" => "Answers for Project Euler",
"games" => "Games written in Perl 6",
"interpreters" => "Language or DSL interpreters",
"module-management" => "Module management",
"parsers" => "Example grammars",
"perlmonks" => "Answers to perlmonks.org questions",
"rosalind" => "Bioinformatics programming problems",
"shootout" => "The Computer Language Benchmark Game",
"tutorial" => "Tutorial examples",
"wsg" => "The Winter Scripting Games",
"other" => "Uncategorized examples",
;
sub MAIN(:$no-highlight = False) {
my %base-categories-table =
"best-of-rosettacode" => "Best of Rosettacode",
"99-problems" => "99 problems",
"cookbook" => "Cookbook examples",
"euler" => "Answers for Project Euler",
"games" => "Games written in Perl 6",
"interpreters" => "Language or DSL interpreters",
"module-management" => "Module management",
"parsers" => "Example grammars",
"perlmonks" => "Answers to perlmonks.org questions",
"rosalind" => "Bioinformatics programming problems",
"shootout" => "The Computer Language Benchmark Game",
"tutorial" => "Tutorial examples",
"wsg" => "The Winter Scripting Games",
"other" => "Uncategorized examples",
;

my %menu-tabs =
"/categories/best-of-rosettacode.html" => "Rosettacode",
"/categories/99-problems.html" => "99 Problems",
"/categories/cookbook.html" => "Cookbook",
"/categories/euler.html" => "Euler",
"/categories/games.html" => "Games",
"/categories/interpreters.html" => "Interpreters",
"/categories/module-management.html" => "Modules",
"/categories/parsers.html" => "Grammars",
"/categories/perlmonks.html" => "Perlmonks",
"/categories/rosalind.html" => "Rosalind",
"/categories/shootout.html" => "Shootout",
"/categories/tutorial.html" => "Tutorial",
"/categories/wsg.html" => "WSG",
"/categories/other.html" => "Other",
;
my %menu-tabs =
"/categories/best-of-rosettacode.html" => "Rosettacode",
"/categories/99-problems.html" => "99 Problems",
"/categories/cookbook.html" => "Cookbook",
"/categories/euler.html" => "Euler",
"/categories/games.html" => "Games",
"/categories/interpreters.html" => "Interpreters",
"/categories/module-management.html" => "Modules",
"/categories/parsers.html" => "Grammars",
"/categories/perlmonks.html" => "Perlmonks",
"/categories/rosalind.html" => "Rosalind",
"/categories/shootout.html" => "Shootout",
"/categories/tutorial.html" => "Tutorial",
"/categories/wsg.html" => "WSG",
"/categories/other.html" => "Other",
;

my $all-categories = Categories.new(categories-table => %base-categories-table);
my $all-categories = Categories.new(categories-table => %base-categories-table);

my %cookbook-categories-table =
"01strings" => "1. Strings",
"02numbers" => "2. Numbers",
"03dates-and-times" => "3. Dates and Times",
"04arrays" => "4. Arrays",
"05hashes" => "5. Hashes",
"06pattern-matching" => "6. Pattern Matching",
"07file-access" => "7. File access",
"09directories" => "9. Directories",
"10subroutines" => "10. Subroutines",
"13classes-objects-and-ties" => "13. Classes, Objects and Ties",
"14database-access" => "14. Database Access",
"16processes" => "16. Processes",
"17sockets" => "17. Sockets",
"19cgi-programming" => "19. CGI programming",
"20web-automation" => "20. Web Automation",
;
my %cookbook-categories-table =
"01strings" => "1. Strings",
"02numbers" => "2. Numbers",
"03dates-and-times" => "3. Dates and Times",
"04arrays" => "4. Arrays",
"05hashes" => "5. Hashes",
"06pattern-matching" => "6. Pattern Matching",
"07file-access" => "7. File access",
"09directories" => "9. Directories",
"10subroutines" => "10. Subroutines",
"13classes-objects-and-ties" => "13. Classes, Objects and Ties",
"14database-access" => "14. Database Access",
"16processes" => "16. Processes",
"17sockets" => "17. Sockets",
"19cgi-programming" => "19. CGI programming",
"20web-automation" => "20. Web Automation",
;

my $cookbook-categories = Categories.new(categories-table => %cookbook-categories-table);
$all-categories.append-subcategories(to-category => "cookbook", subcategories => $cookbook-categories);
my $cookbook-categories = Categories.new(categories-table => %cookbook-categories-table);
$all-categories.append-subcategories(to-category => "cookbook", subcategories => $cookbook-categories);

my %wsg-categories-table =
"beginner-2007" => "Beginner-level problems 2007",
"beginner-2008" => "Beginner-level problems 2008",
"advanced-2008" => "Advanced-level problems 2008",
;
my %wsg-categories-table =
"beginner-2007" => "Beginner-level problems 2007",
"beginner-2008" => "Beginner-level problems 2008",
"advanced-2008" => "Advanced-level problems 2008",
;

my $wsg-categories = Categories.new(categories-table => %wsg-categories-table);
$all-categories.append-subcategories(to-category => "wsg", subcategories => $wsg-categories);
my $wsg-categories = Categories.new(categories-table => %wsg-categories-table);
$all-categories.append-subcategories(to-category => "wsg", subcategories => $wsg-categories);

my $website = Website.new(categories => $all-categories);
$website.menu-tabs = %menu-tabs;
$website.build;
say "no highlight ", $no-highlight;
my $website = Website.new(categories => $all-categories);
$website.syntax-highlighting = False if $no-highlight;
$website.menu-tabs = %menu-tabs;
$website.build;
}

# vim: expandtab shiftwidth=4 ft=perl6
1 change: 1 addition & 0 deletions lib/Pod/Htmlify.pm6
Expand Up @@ -9,6 +9,7 @@ class Website is export {
has $.categories is rw;
has $.base-html-dir is rw = "html";
has $.base-categories-dir is rw = "categories";
has $.syntax-highlighting is rw = True;
has %.menu-tabs;

submethod BUILD(:$categories) {
Expand Down
12 changes: 11 additions & 1 deletion t/004-website.t
Expand Up @@ -5,7 +5,7 @@ use Test;
use Perl6::Examples;
use Pod::Convenience;

plan 11;
plan 12;

use-ok("Pod::Htmlify");

Expand Down Expand Up @@ -76,6 +76,16 @@ subtest {
is($website.base-html-dir, "html", "base html directory");
}, "Website object instantiation";

subtest {
plan 2;

my $website = Website.new;
is $website.syntax-highlighting, True, "syntax highlighting on by default";
$website.syntax-highlighting = False;
is $website.syntax-highlighting, False,
"syntax highlighting turned off successfully";
}, "--no-highlight option";

subtest {
plan 1;

Expand Down

0 comments on commit 8a9c60d

Please sign in to comment.