[MKDoc-commit] [MKDoc-Text-Structured] Added basic text2xhtml command line tool

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Thu Aug 18 16:05:12 BST 2005


Log Message:
-----------
[MKDoc-Text-Structured] Added basic text2xhtml command line tool

Modified Files:
--------------
    MKDoc-Text-Structured:
        Changes
        MANIFEST
        META.yml
        Makefile.PL
        README

Added Files:
-----------
    MKDoc-Text-Structured/bin:
        text2xhtml

-------------- next part --------------
Index: MANIFEST
===================================================================
RCS file: /var/spool/cvs/MKDoc-Text-Structured/MANIFEST,v
retrieving revision 1.7
retrieving revision 1.8
diff -LMANIFEST -LMANIFEST -u -r1.7 -r1.8
--- MANIFEST
+++ MANIFEST
@@ -1,4 +1,5 @@
 .cvsignore
+bin/text2xhtml
 Changes
 lib/MKDoc/Text/Structured.pm
 lib/MKDoc/Text/Structured/Base.pm
Index: META.yml
===================================================================
RCS file: /var/spool/cvs/MKDoc-Text-Structured/META.yml,v
retrieving revision 1.7
retrieving revision 1.8
diff -LMETA.yml -LMETA.yml -u -r1.7 -r1.8
--- META.yml
+++ META.yml
@@ -5,6 +5,7 @@
 version_from: lib/MKDoc/Text/Structured.pm
 installdirs:  site
 requires:
+    Getopt::Declare:               
     Scalar::Util:                  1.07
     Test::More:                    0.47
     URI::Find:                     0.13
Index: Changes
===================================================================
RCS file: /var/spool/cvs/MKDoc-Text-Structured/Changes,v
retrieving revision 1.27
retrieving revision 1.28
diff -LChanges -LChanges -u -r1.27 -r1.28
--- Changes
+++ Changes
@@ -7,6 +7,7 @@
     - documented MKDoc::Text::Structured::Inline
     - wrap smilies in CSS classes
     - Added support for <a rel="nofollow" href="...
+    - Added basic text2xhtml command line tool
 
 0.82 Thu Mar 31 13:45:00 2005
     - fixed failure to change " to &quot; bug
Index: README
===================================================================
RCS file: /var/spool/cvs/MKDoc-Text-Structured/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -LREADME -LREADME -u -r1.2 -r1.3
--- README
+++ README
@@ -3,6 +3,7 @@
 
 
 SUMMARY
+-------
 
 MKDoc::Text::Structured is a library which allows very simple
 text construct to be turned into HTML. These constructs are the ones
@@ -16,6 +17,7 @@
 
 
 INSTALLATION
+------------
 
 To install this module type the following:
 
@@ -28,23 +30,26 @@
 
 
 DEPENDENCIES
+------------
 
-  none.
+none.
 
 
-MISCELLEANOUS
+MISCELLANEOUS
+-------------
 
-  Want to help us open-source MKDoc?
-  Join the MKDoc-Modules community!
+Want to help us open-source MKDoc?
+Join the MKDoc-Modules community!
 
-  http://lists.webarch.co.uk/mailman/listinfo/mkdoc-modules
+http://lists.webarch.co.uk/mailman/listinfo/mkdoc-modules
  
 
 COPYRIGHT AND LICENCE
+---------------------
 
-  This module free software and is distributed under the
-  same license as Perl itself.
+This module free software and is distributed under the
+same license as Perl itself.
 
-  Copyright (C) 2003 MKDoc Holdings Ltd.
+Copyright (C) 2003 MKDoc Holdings Ltd.
 
-  Author: Jean-Michel Hiver
+Author: Jean-Michel Hiver and others
Index: Makefile.PL
===================================================================
RCS file: /var/spool/cvs/MKDoc-Text-Structured/Makefile.PL,v
retrieving revision 1.3
retrieving revision 1.4
diff -LMakefile.PL -LMakefile.PL -u -r1.3 -r1.4
--- Makefile.PL
+++ Makefile.PL
@@ -4,10 +4,12 @@
 WriteMakefile(
     'NAME'		=> 'MKDoc::Text::Structured',
     'VERSION_FROM'      => 'lib/MKDoc/Text/Structured.pm', # finds $VERSION
+    'EXE_FILES'         => [ 'bin/text2xhtml' ],
     'PREREQ_PM'		=> {
         'Test::More'    => '0.47',
         'Scalar::Util'  => '1.07',
         'URI::Find'	=> '0.13',
+        'Getopt::Declare' => '',
     },
     ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
       (ABSTRACT_FROM => 'lib/MKDoc/Text/Structured.pm', # retrieve abstract from module
--- /dev/null
+++ bin/text2xhtml
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use lib ('lib');
+
+use Getopt::Declare;
+use MKDoc::Text::Structured;
+our $VERSION = $MKDoc::Text::Structured::VERSION;
+
+my $usage = q(
+
+  [nocase] [strict]
+  [mutex: --body-only --inline-only --entities-only]
+
+  --help			display this help
+  --version			display information about version
+  --external-stylesheet <file>	set external stylesheet as <file>
+  --title <title>		set page title as <title>
+  --body-only			output only the <body> tag content
+  --inline-only			don't create any block-level tags
+  --entities-only		don't create any tags at all
+
+);
+
+my $arg = new Getopt::Declare ($usage);
+
+my $title = '';
+if ($arg->{'--title'})
+{
+    $title = $arg->{'--title'};
+    $title = MKDoc::Text::Structured::Inline::process_entities_only ($title);
+}
+
+my $style = '';
+if ($arg->{'--external-stylesheet'})
+{
+    $style = $arg->{'--external-stylesheet'};
+    $style = MKDoc::Text::Structured::Inline::process_entities_only ($style);
+    $style = qq(<style media="screen" type="text/css" title="Screen style sheet">
+\@import url($style);
+</style>\n);
+}
+
+my $text = join '', <STDIN>;
+
+my $html;
+
+if ($arg->{'--inline-only'})
+{ $html = MKDoc::Text::Structured::Inline::process ($text); }
+
+elsif ($arg->{'--entities-only'})
+{ $html = MKDoc::Text::Structured::Inline::process_entities_only ($text); }
+
+else
+{ $html = MKDoc::Text::Structured::process ($text); }
+
+unless ($arg->{'--body-only'} or $arg->{'--inline-only'} or $arg->{'--entities-only'}) 
+{
+    print STDOUT qq(<?xml version="1.0"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>$title</title>
+<meta name="generator" content="MKDoc::Text::Structured" />
+$style</head>
+<body>
+$html
+</body>
+</html>);
+}
+else
+{
+    print STDOUT $html;
+}
+
+1;
+


More information about the MKDoc-commit mailing list