From 5a5deeca725aaa7054baeec74a56df7c58cdc40a Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 30 Sep 2020 18:41:01 -0700 Subject: [PATCH] Markdown.pl: refactor style sheet generation Create a new "GenerateStyleSheet" function that returns a copy of the internal fancy style sheet using the given prefix as a prefix of all the CSS style names. Use the new "GenerateStyleSheet" function to create the style sheet as needed. Signed-off-by: Kyle J. McKay --- Markdown.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index 75576c7..a6851c0 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -437,11 +437,7 @@ HTML4 $out .= "$title\n"; } } - if ($options{show_styles}) { - my $stylesheet = $g_style_sheet; - $stylesheet =~ s/%\(base\)/$g_style_prefix/g; - $out .= $stylesheet; - } + $out .= GenerateStyleSheet($g_style_prefix) if $options{show_styles}; if ($stub) { $out .= "\n\n" . "
\n"; @@ -489,6 +485,19 @@ HTML4 } +# Return a copy of the fancy CSS style sheet that uses the +# passed in prefix as a prefix for the CSS style names. +# If no argument is passed in, use $g_style_prefix +# as the CSS style name prefix. +sub GenerateStyleSheet { + my $prefix = shift; + defined($prefix) or $prefix = $g_style_prefix; + my $stylesheet = $g_style_sheet; + $stylesheet =~ s/%\(base\)/$g_style_prefix/g; + return $stylesheet; +} + + sub _xmlcheck { my $text = shift; my ($good, $errs);