Skip to content

Commit

Permalink
Perform a bit of html validation for PGML tag blocks that are spans.
Browse files Browse the repository at this point in the history
A span tag block is not allowed to contain any PGML blocks that have the
type indent, align, par, list, bullet, answer, heading, rule, code, pre,
verbatim, table, or tag.  If a span tag block is detected with any of
those things in it, a warning is issued and the contents rendered
directly without the span tag.  This helps to prevent problem authors
from doing the wrong thing.

It is valid for a span to contain a span, but if a span tag block
contains another tag bloc, the outer span tag block does not have the
information to determine what the inner tag block is (span or div).
Since I don't think it is particularly useful to have a span within a
span, I just blocked any tag block in a span.
  • Loading branch information
drgrice1 committed Apr 7, 2024
1 parent ac6f9b2 commit ee33ad2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions macros/core/PGML.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,15 @@ sub Tag {
PGML::Warning qq{The tag "$tag" is not allowed};
return $self->string($item);
}
if ($tag eq 'span') {
for my $subblock (@{ $item->{stack} }) {
if ($subblock->{type} =~ /^(indent|align|par|list|bullet|answer|heading|rule|code|pre|verbatim|table|tag)$/)
{
PGML::Warning qq{A "span" tag may not contain a $subblock->{type}};
return $self->string($item);
}
}
}
return main::tag($tag, @attributes, $self->string($item));
}

Expand Down

0 comments on commit ee33ad2

Please sign in to comment.