Permalink
Browse files

add some i18n, change fromat of =AUTHOR

  • Loading branch information...
1 parent db7bde2 commit 3554ad14b68c2136d551ec0a3ce06345b21fc945 @zag committed Jul 19, 2012
View
@@ -1,7 +1,7 @@
use Module::Build;
use v5.10;
Module::Build->new
- ( module_name => 'Writeat',
+ ( module_name => 'WriteAt',
license => 'perl',
prereq => {
'Regexp::Grammars'=>1.015,
@@ -11,11 +11,11 @@ Module::Build->new
script_files=>[qw!
scripts/writeat
!],
- dist_version_from=>'lib/Writeat.pm',
+ dist_version_from=>'lib/WriteAt.pm',
meta_merge=>{
resources=> {
repository => 'git://github.com/zag/writeat.git',
- bugtracker=>'http://rt.cpan.org/Public/Dist/Display.html?Name=Writeat'
+ bugtracker=>'http://rt.cpan.org/Public/Dist/Display.html?Name=WriteAt'
}
},
dist_author=>'Zahatski Aliaksandr zag@cpan.org',
View
@@ -1,4 +1,8 @@
-Revision history for Perl extension Writeat.
+Revision history for Perl extension WriteAt.
+0.02
+ + rename to WriteAt,
+ + add russian SEMANTIC blocks
+ + change =AUTHOR content
0.01
- + initial release of Writeat suite
+ + initial release of WriteAt suite
View
4 README
@@ -1,7 +1,7 @@
-Writeat
+WriteAt
=====================
-Writeat - suite for make books and docs in pod6 format
+WriteAt - suite for make books and docs in pod6 format
INSTALLATION
View
@@ -0,0 +1,163 @@
+#===============================================================================
+#
+# DESCRIPTION: WriteAt - suite for book writers
+#
+# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com>
+#===============================================================================
+package WriteAt;
+
+=head1 NAME
+
+WriteAt - suite for make books and docs in pod6 format
+
+=head1 SYNOPSIS
+
+
+ =TITLE MyBook
+ =SUBTITLE My first free book
+ =AUTHOR Alex Green
+ =DESCRIPTION Short description about this book
+ =begin CHANGES
+ Aug 18th 2010(v0.2)[zag] preface
+
+ May 27th 2010(v0.1)[zag] Initial version
+ =end CHANGES
+
+ =Include src/book_preface.pod
+ =CHAPTER Intro
+
+ B<Pod> is an evolution of Perl 5's L<I<Plain Ol' Documentation>|doc:perlpod>
+ (POD) markup. Compared to Perl 5 POD, Perldoc's Pod dialect is much more
+ uniform, somewhat more compact, and considerably more expressive. The
+ Pod dialect also differs in that it is a purely descriptive mark-up
+ notation, with no presentational components.
+
+=head1 DESCRIPTION
+
+Books must be high available for readers and writers !
+WriteAt - suite for free book makers. It help make and prepare book for publishing.
+
+=head1 INSTALLATION
+
+There are several ways to install C<WriteAt> to your system.
+
+=head2 Install under Ubuntu
+
+ sudo add-apt-repository ppa:zahatski/ppa
+ sudo apt-get install writeat
+
+=head2 From CPAN
+
+ cpanm WriteAt
+
+For book creation it is necessary following software:
+
+ * docbook-4.5
+ * xslt processor
+ * GNU make
+
+=head2 Checkout templates
+
+Grab template:
+
+ git clone https://github.com/zag/writeat-tmpl-firstbook.git
+ cd writeat-tmpl-firstbook
+ make
+
+Point your web brouser to С<index.html> file in C<work> directory.
+
+=cut
+
+use strict;
+use warnings;
+use v5.10;
+our $VERSION = '0.01';
+use WriteAt::CHANGES;
+use WriteAt::AUTHOR;
+use WriteAt::To::DocBook;
+use utf8;
+
+=head1 FUNCTIONS
+
+=cut
+
+sub get_name_from_locale {
+ my $name = shift;
+ my %SEM = (
+ TITLE => [ qr/TITLE/, qr/^ЗАГОЛОВОК/ ],
+ SUBTITLE => [ qr/SUBTITLE/, qr/ПОДЗАГОЛОВОК/ ],
+ AUTHOR => [ qr/AUTHOR/, qr/АВТОР/ ],
+ CHANGES => [ qr/CHANGES/, qr/ИЗМЕНЕНИЯ/ ],
+ DESCRIPTION => [ qr/DESCRIPTION/, qr/ОПИСАНИЕ/ ]
+ );
+ while ( my ( $k, $v ) = each %SEM ) {
+ foreach my $reg (@$v) {
+ if ( $name =~ $reg ) {
+ return $k;
+ }
+ }
+
+ }
+ return undef;
+}
+
+sub get_book_info_blocks {
+ my $tree = shift;
+ my $res = shift || return;
+ my $to = shift;
+ my @nodes = ref($tree) eq 'ARRAY' ? @$tree : ($tree);
+ my @tree = ();
+ foreach my $n (@nodes) {
+ unless ( ref($n) ) { #skip text
+ push @tree, $n;
+ next;
+ }
+
+ #convert =Include $n to DOM if To::* passed
+ if ( $to && $n->name eq 'Include' ) {
+ $n = $to->_make_dom_node($n);
+ }
+ if ( my $converted_block_name = &get_name_from_locale( $n->name ) ) {
+ push @{$res->{$converted_block_name}}, $n;
+ # overwrite original name
+ $n->{name} = $converted_block_name;
+ }
+ else {
+ push @tree, $n;
+ $n->childs( &get_book_info_blocks( $n->childs, $res, $to ) );
+ }
+ }
+ \@tree;
+}
+
+=head1 METHODS
+=cut
+
+sub new {
+ my $class = shift;
+ bless( ( $#_ == 0 ) ? shift : {@_}, ref($class) || $class );
+}
+
+1;
+__END__
+
+=head1 SEE ALSO
+
+Perl6::Pod,
+The world's first book in the pod6 format: Russian book "Everything about Perl 6" L<https://github.com/zag/ru-perl6-book>,
+book template: L<https://github.com/zag/writeat-tmpl-firstbook.git>,
+russian book template: L<https://github.com/zag/writeat-tmpl-firstbook-ru.git>
+
+=head1 AUTHOR
+
+Zahatski Aliaksandr, <zag@cpan.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2012 by Zahatski Aliaksandr
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
@@ -4,8 +4,7 @@
#
# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
-#$Id$
-package Writeat::AUTHOR;
+package WriteAt::AUTHOR;
use strict;
use warnings;
use Perl6::Pod::Block;
@@ -15,10 +14,10 @@ use base 'Perl6::Pod::Block';
Convert:
- *AUTHOR
- firstname: Alex
- surname: Bom
- lineage: Bred
+ *AUTHOR firstname [lineage ] surname
+
+ *AUTHOR Alex Bred Bom
+ *AUTHOR Alex Bom
To
@@ -33,7 +32,13 @@ To
sub parse_content {
my $self = shift;
my $t = shift;
- my %items = $t=~m/^(\w+)\s*:\s*(.+?)\s*$/mg;
+ my @words = grep {defined $_ } $t=~m/^ \s* (\S+) \s+ (?:(\S+)\s+)? (\S+)/x;
+ my %items = ();
+ if (scalar(@words) > 2 ) {
+ @items{qw/ firstname lineage surname /} = @words;
+ } else {
+ @items{qw/ firstname surname /} = @words;
+ }
return \%items;
}
@@ -4,7 +4,7 @@
#
# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
-package Writeat::CHANGES;
+package WriteAt::CHANGES;
use strict;
use warnings;
use Perl6::Pod::Block;
@@ -4,7 +4,7 @@
#
# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
-package Writeat::To;
+package WriteAt::To;
sub block_DESCRIPTION {};
sub block_SUBTITLE{};
sub block_TITLE{};
@@ -4,10 +4,11 @@
#
# AUTHOR: Aliaksandr P. Zahatski, <zahatski@gmail.com>
#===============================================================================
-package Writeat::To::DocBook;
+package WriteAt::To::DocBook;
use Perl6::Pod::Utl;
-use Writeat::To;
-use base ('Perl6::Pod::To::DocBook', 'Writeat::To');
+use WriteAt::To;
+use base ('Perl6::Pod::To::DocBook', 'WriteAt::To');
+use utf8;
sub block_DESCRIPTION {
my ($self, $n) = @_;
@@ -33,6 +34,12 @@ sub block_SUBTITLE{
$w->raw('</subtitle>');
};
+# alias for CHAPTER
+sub block_ГЛАВА {
+ $self = shift;
+ return $self->block_CHAPTER(@_)
+}
+
sub block_CHAPTER {
my ( $self, $node ) = @_;
Oops, something went wrong.

0 comments on commit 3554ad1

Please sign in to comment.