The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MKDoc::XML::Tagger::Preserve - Don't double-tag stuff.

SYNOPSIS

  use MKDoc::XML::Tagger::Preserve;
  print MKDoc::XML::Tagger->process_data (
      [ a ]
      "Hello, <a>Cool World</a>. This World is tagged.",
      { _expr => 'World', _tag => 'strong', class => 'superFort' }
  );

Should print:

  Hello, <a>Cool World</a>. This <strong class="superFort">World</strong> is tagged.

SUMMARY

MKDoc::XML::Tagger::Preserve does the same thing as MKDoc::XML::Tagger except it lets you define which tags you don't want to be tagged.

Let's say that you have an XHTML fragment with some hyperlinks in it. You want to hyperlink this fragment, but, of course, you do not want the content of the existing hyperlinks to be hyperlinked again.

Instead of using MKDoc::XML::Tagger:

  return MKDoc::XML::Tagger->process ($fragment, @links);

You use MKDoc::XML::Tagger::Preserve:

  return MKDoc::XML::Tagger::Preserve->process ( [ 'a' ], $fragment, @links);

DISCLAIMER

This module does low level XML manipulation. It will somehow parse even broken XML and try to do something with it. Do not use it unless you know what you're doing.

NOTES

Don't expect MKDoc::XML::Tagger::Preserve to do anything clever with tags which have nested tags in them, i.e. tags such as <small>.

MKDoc::XML::Tagger::Preserve uses a very simple regex to take the tags which you want to preserve out so with nested <small> for example, it's guaranteed to fail and product incorrect XHTML.

AUTHOR

Copyright 2003 - MKDoc Holdings Ltd.

Author: Jean-Michel Hiver <jhiver@mkdoc.com>

This module is free software and is distributed under the same license as Perl itself. Use it at your own risk.

SEE ALSO

MKDoc::XML::Tagger