File: 0002-Behave-as-a-module-if-used-as-one.patch

package info (click to toggle)
markdown 1.0.1-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 5,640; makefile: 4; sh: 3
file content (85 lines) | stat: -rw-r--r-- 2,278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Description: Behave as a module if used as one
Author: Joey Hess <joeyh@debian.org>
Origin: vendor, https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=356143;filename=markdown-md;msg=17
Bug-Debian: https://bugs.debian.org/356143
Forwarded: no
Reviewed-by: Matt Kraai <kraai@debian.org>
Last-Update: 2006-03-10
---
 Markdown.pl | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/Markdown.pl b/Markdown.pl
index 6e92f4a..3319e50 100755
--- a/Markdown.pl
+++ b/Markdown.pl
@@ -64,6 +64,9 @@ my %g_html_blocks;
 # (see _ProcessListItems() for details):
 my $g_list_level = 0;
 
+# Check to see if Markdown.pm has been loaded; if so we must be loaded
+# as a perl module.
+my $g_perl_module = exists $INC{'Markdown.pm'};
 
 #### Blosxom plug-in interface ##########################################
 
@@ -87,8 +90,8 @@ sub story {
 
 
 #### Movable Type plug-in interface #####################################
-eval {require MT};  # Test to see if we're running in MT.
-unless ($@) {
+eval {require MT} unless $g_perl_module;  # Test to see if we're running in MT.
+unless ($g_perl_module || $@) {
     require MT;
     import  MT;
     require MT::Template::Context;
@@ -178,7 +181,7 @@ unless ($@) {
 		});
 	}
 }
-else {
+elsif (! $g_perl_module) {
 #### BBEdit/command-line text filter interface ##########################
 # Needs to be hidden from MT (and Blosxom when running in static mode).
 
@@ -189,7 +192,7 @@ else {
 
 		#### Check for command-line switches: #################
 		my %cli_opts;
-		use Getopt::Long;
+		eval {use Getopt::Long}; # don't load in library mode
 		Getopt::Long::Configure('pass_through');
 		GetOptions(\%cli_opts,
 			'version',
@@ -1325,14 +1328,15 @@ __END__
 
 =head1 NAME
 
-B<Markdown>
+B<markdown>
 
 
 =head1 SYNOPSIS
 
-B<Markdown.pl> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ]
-    [ I<file> ... ]
+B<markdown> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ] [ I<file> ... ]
 
+use Markdown;
+$html=Markdown::Markdown($text);
 
 =head1 DESCRIPTION
 
@@ -1355,7 +1359,7 @@ For more information about Markdown's syntax, see:
 
 Use "--" to end switch parsing. For example, to open a file named "-z", use:
 
-	Markdown.pl -- -z
+	markdown -- -z
 
 =over 4
 
-- 
2.43.0