+sub parse_first_line {
+ my $self = shift;
+ my $line = shift || "";
+
+ if ($line =~ m/([^\s]+)set-tag-style([^\s]+)/) {
+ if ($1 eq $2) {
+ $self->{error} = "The tag start and end markers must not be equal.";
+ return 0;
+ }
+
+ $self->set_tag_style($1, $2);
+ }
+
+ return 1;
+}
+
+sub _parse_config_option {
+ my $self = shift;
+ my $line = shift;
+
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+
+ my ($key, $value) = split m/\s*=\s*/, $line, 2;
+
+ if ($key eq 'tag-style') {
+ $self->set_tag_style(split(m/\s+/, $value, 2));
+ }
+}
+
+sub _parse_config_lines {
+ my $self = shift;
+ my $lines = shift;
+
+ my ($comment_start, $comment_end) = ("", "");
+
+ if (ref $self eq 'LaTeXTemplate') {
+ $comment_start = '\s*%';
+ } elsif (ref $self eq 'HTMLTemplate') {
+ $comment_start = '\s*<!--';
+ $comment_end = '>\s*';
+ } else {
+ $comment_start = '\s*\#';
+ }
+
+ my $num_lines = scalar @{ $lines };
+ my $i = 0;
+
+ while ($i < $num_lines) {
+ my $line = $lines->[$i];
+
+ if ($line !~ m/^${comment_start}\s*config\s*:(.*)${comment_end}$/i) {
+ $i++;
+ next;
+ }
+
+ $self->_parse_config_option($1);
+ splice @{ $lines }, $i, 1;
+ $num_lines--;
+ }
+}
+