---
name: "MsOffice::Word::Surgeon::Utils"
section: "3pm"
platform: "linux"
package: "libmsoffice-word-surgeon-perl"
version: "2.10-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MsOffice::Word::Surgeon::Utils"
---

# MsOffice::Word::Surgeon::Utils(3pm)

utility functions for MsOffice::Word::Surgeon

## NAME

MsOffice::Word::Surgeon::Utils - utility functions for MsOffice::Word::Surgeon

## SYNOPSIS

```
  use MsOffice::Word::Surgeon::Utils qw(maybe_preserve_spaces);
  my $attr = maybe_preserve_spaces($some_text);
```

## DESCRIPTION

Functions in this module are used internally by MsOffice::Word::Surgeon.

## FUNCTIONS

### maybe\_preserve\_spaces

```
  my $attr = maybe_preserve_spaces($some_text);
```

Returns the XML attribute to be inserted into `"<w:t>"` nodes and  `"<w:delText>"` nodes when the literal text within the node starts or ends with a space -- in that case the XML should contain the  attribute `"xml:space="preserve""`

### is\_at\_run\_level

```
   if (is_at_run_level($xml)) {...}
```

Returns true if the given XML fragment ends with a `"</w:r>"`, `"</w:del>"` or `"</w:ins>"` node.

### parse\_attrs

```
  my %attrs = parse_attrs($lst_attrs)
```

Returns a hash of name-value pairs parsed from the input string. Values may be enclosed in single or in double quotes. Values are entity-decoded.

### decode\_entities

```
  decode_entities($string)
```

Decodes XML entities within the supplied string (in-place decoding).

### encode\_entities

```
  encode_entities($string)
```

Encodes XML entities within the supplied string (in-place encoding).

## COPYRIGHT AND LICENSE

Copyright 2019-2024 by Laurent Dami.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
