From 93a3719a5deff6297ce7be97939dba1d0155dde0 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 13 Aug 2012 14:30:30 -0400 Subject: Move MarkdownBook modules into Text namespace. --- diff --git a/bin/markdownbook.pl b/bin/markdownbook.pl index cceecdb..48c0cd6 100755 --- a/bin/markdownbook.pl +++ b/bin/markdownbook.pl @@ -18,7 +18,7 @@ use strict; use warnings; -use MarkdownBook::Book; +use Text::MarkdownBook::Book; my $format; my $doc_dir; @@ -26,7 +26,7 @@ my $book; ($format, $doc_dir) = @ARGV; -$book = MarkdownBook::Book->new($format, $doc_dir); +$book = Text::MarkdownBook::Book->new($format, $doc_dir); $book->parse(); $book->output(); diff --git a/lib/MarkdownBook/Book.pm b/lib/Text/MarkdownBook/Book.pm index 4f30afb..4c49d1d 100644 --- a/lib/MarkdownBook/Book.pm +++ b/lib/Text/MarkdownBook/Book.pm @@ -18,7 +18,7 @@ use warnings; use Carp; -package MarkdownBook::Book; +package Text::MarkdownBook::Book; sub new { @@ -34,7 +34,7 @@ sub new Carp::croak('Invalid format "' . $format . '"'); } eval { - require 'MarkdownBook/Document/' . $format . '.pm'; + require 'Text/MarkdownBook/Document/' . $format . '.pm'; 1; } or Carp::croak('Unsupported format "' . $format . '"'); $self->{'format'} = $format; @@ -93,7 +93,7 @@ sub _get_document_module { my ($self) = @_; - return 'MarkdownBook::Document::' . $self->{'format'}; + return 'Text::MarkdownBook::Document::' . $self->{'format'}; } sub create_documents @@ -156,7 +156,7 @@ sub add_section push(@{$self->{'sections'}}, $section); # Index sections (not documents) by ID. - if (ref($section) eq 'MarkdownBook::Section') { + if (ref($section) eq 'Text::MarkdownBook::Section') { $self->{'sections_by_id'}->{$section->id()} = $section; } } @@ -216,7 +216,7 @@ sub _do_gen_toc foreach $section (@{$self->{'sections'}}) { $toc .= "\n" if $toc ne ''; - if (ref($section) =~ m/^MarkdownBook::Document/) { + if (ref($section) =~ m/^Text::MarkdownBook::Document/) { next if $section->type() eq 'index'; $toc .= ' * ['; $toc .= $section->id(); @@ -225,7 +225,7 @@ sub _do_gen_toc $toc .= ']['; $toc .= $section->file(); $toc .= ']'; - } elsif (ref($section) eq 'MarkdownBook::Section') { + } elsif (ref($section) eq 'Text::MarkdownBook::Section') { $toc .= ' ' x $section->level(); $toc .= ($section->level() == 1 ? ' - [' : ' * ['); $toc .= $section->number(); diff --git a/lib/MarkdownBook/Document.pm b/lib/Text/MarkdownBook/Document.pm index 2a30396..af16be4 100644 --- a/lib/MarkdownBook/Document.pm +++ b/lib/Text/MarkdownBook/Document.pm @@ -16,10 +16,10 @@ use strict; use warnings; -use MarkdownBook::Section; +use Text::MarkdownBook::Section; use Carp; -package MarkdownBook::Document; +package Text::MarkdownBook::Document; sub new { @@ -230,7 +230,7 @@ sub _do_heading /$1/x; # Create and store section object. - $section = MarkdownBook::Section->new($self, + $section = Text::MarkdownBook::Section->new($self, $level, $section_number, $section_id, $section_title); push(@{$self->{'sections'}}, $section); $self->{'book'}->add_section($section); diff --git a/lib/MarkdownBook/Document/html.pm b/lib/Text/MarkdownBook/Document/html.pm index 60f22c7..e074de0 100644 --- a/lib/MarkdownBook/Document/html.pm +++ b/lib/Text/MarkdownBook/Document/html.pm @@ -16,16 +16,16 @@ use strict; use warnings; -use MarkdownBook::Document; -use MarkdownBook::HTMLTree; +use Text::MarkdownBook::Document; +use Text::MarkdownBook::HTMLTree; use Carp; use Text::Markdown; use HTML::TreeBuilder; use HTML::Template; -package MarkdownBook::Document::html; +package Text::MarkdownBook::Document::html; -our @ISA = qw(MarkdownBook::Document); +our @ISA = qw(Text::MarkdownBook::Document); sub output { @@ -84,14 +84,15 @@ sub _do_set_heading_id_attrs $self->{'tree'}->eof($text); # Find the "body" element. - @{$self->{'tree_body'}} = MarkdownBook::HTMLTree::find_elements_by_tag_names( - $self->{'tree'}, ('body')); + @{$self->{'tree_body'}} = + Text::MarkdownBook::HTMLTree::find_elements_by_tag_names( + $self->{'tree'}, ('body')); # Don't modify headings of index documents. return if $self->{'type'} eq 'index'; # Find all headings. - @headings = MarkdownBook::HTMLTree::find_elements_by_tag_names( + @headings = Text::MarkdownBook::HTMLTree::find_elements_by_tag_names( @{$self->{'tree_body'}}[0], ('h1', 'h2')); # Set "id" attributes. diff --git a/lib/MarkdownBook/Document/txt.pm b/lib/Text/MarkdownBook/Document/txt.pm index f150477..f2a8a77 100644 --- a/lib/MarkdownBook/Document/txt.pm +++ b/lib/Text/MarkdownBook/Document/txt.pm @@ -16,12 +16,12 @@ use strict; use warnings; -use MarkdownBook::Document; +use Text::MarkdownBook::Document; use Carp; -package MarkdownBook::Document::txt; +package Text::MarkdownBook::Document::txt; -our @ISA = qw(MarkdownBook::Document); +our @ISA = qw(Text::MarkdownBook::Document); sub output { diff --git a/lib/MarkdownBook/HTMLTree.pm b/lib/Text/MarkdownBook/HTMLTree.pm index e01bab0..6080475 100644 --- a/lib/MarkdownBook/HTMLTree.pm +++ b/lib/Text/MarkdownBook/HTMLTree.pm @@ -18,7 +18,7 @@ use warnings; use HTML::Element; -package MarkdownBook::HTMLTree; +package Text::MarkdownBook::HTMLTree; sub find_elements_by_tag_names { diff --git a/lib/MarkdownBook/Section.pm b/lib/Text/MarkdownBook/Section.pm index 82ff897..75e13b8 100644 --- a/lib/MarkdownBook/Section.pm +++ b/lib/Text/MarkdownBook/Section.pm @@ -16,7 +16,7 @@ use strict; use warnings; -package MarkdownBook::Section; +package Text::MarkdownBook::Section; sub new { -- cgit v0.9.1