summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-04-05 23:29:44 (GMT)
committerDavid A. Madore <david+git@madore.org>2010-04-05 23:29:44 (GMT)
commitd785250b91e47275de7a2a79851bafd0ed9231cc (patch)
treee7955aef7a7076dda09d001e9ae352351d36a551
parentaa29adbaf3b50882cf7b65e939453e6928df5a18 (diff)
downloadblogengine-d785250b91e47275de7a2a79851bafd0ed9231cc.zip
blogengine-d785250b91e47275de7a2a79851bafd0ed9231cc.tar.gz
blogengine-d785250b91e47275de7a2a79851bafd0ed9231cc.tar.bz2
Unuglify use of create_meta_element_helper.
-rwxr-xr-xdaml2html.pl35
1 files changed, 21 insertions, 14 deletions
diff --git a/daml2html.pl b/daml2html.pl
index ec4c139..857c3da 100755
--- a/daml2html.pl
+++ b/daml2html.pl
@@ -393,15 +393,7 @@ sub create_meta_element_helper {
}
$meta->setAttributeNS("", $name_or_http_equiv, $meta_name);
$meta->setAttributeNS("", "content", $meta_content);
- if ( defined($src_node) ) {
-# ($doc->documentElement)->appendChild($meta); # Work around libxml2 bug <URL: https://bugzilla.gnome.org/show_bug.cgi?id=614068 >
- $src_node->replaceNode($meta);
- } else {
- die "\$head_node should have been defined at this point"
- unless defined($head_node);
- $head_node->appendChild($meta);
- $head_node->appendChild($doc->createTextNode("\n"));
- }
+ return $meta;
}
sub create_style_or_script_node {
@@ -452,8 +444,14 @@ sub daml_handler {
$html_node->appendChild($head_node);
$html_node->appendChild($doc->createTextNode("\n"));
$head_node->appendChild($doc->createTextNode("\n"));
- create_meta_element_helper(undef, "http-equiv", "Content-Type", "text/html; charset=utf-8");
- create_meta_element_helper(undef, "http-equiv", "Content-Language", $lang) if $lang;
+ $head_node->appendChild(
+ create_meta_element_helper(undef, "http-equiv",
+ "Content-Type", "text/html; charset=utf-8"));
+ $head_node->appendChild($doc->createTextNode("\n"));
+ $head_node->appendChild(
+ create_meta_element_helper(undef, "http-equiv",
+ "Content-Language", $lang)) if $lang;
+ $head_node->appendChild($doc->createTextNode("\n"));
my @child_nodes = $node->childNodes;
my @to_process;
foreach my $child ( @child_nodes ) {
@@ -568,7 +566,12 @@ sub title_handler {
# ($doc->documentElement)->appendChild($title_node); # Work around libxml2 bug <URL: https://bugzilla.gnome.org/show_bug.cgi?id=614068 >
$node->replaceNode($title_node);
$title_node->appendChild($doc->createTextNode($title_text));
- create_meta_element_helper undef, "name", "Title", $title_text, $src_title_explicit_lang;
+ my $title_parent = $title_node->parentNode;
+ $title_parent->insertAfter(
+ create_meta_element_helper(undef, "name", "Title",
+ $title_text, $src_title_explicit_lang),
+ $title_node);
+ $title_parent->insertAfter($doc->createTextNode("\n"), $title_node);
}
}
@@ -593,9 +596,13 @@ sub meta_handler {
my $optref = shift;
print STDERR "warning: meta handler doesn't handle arguments\n" if @_;
if ( $node->localName eq "meta-description" ) {
- create_meta_element_helper $node, "name", "Description", $node->textContent;
+ $node->replaceNode(
+ create_meta_element_helper($node, "name",
+ "Description", $node->textContent));
} elsif ( $node->localName eq "meta-keywords" ) {
- create_meta_element_helper $node, "name", "Keywords", $node->textContent;
+ $node->replaceNode(
+ create_meta_element_helper($node, "name",
+ "Keywords", $node->textContent));
}
}