Parse::Man::DOM(3pm) User Contributed Perl Documentation Parse::Man::DOM(3pm)

"Parse::Man::DOM" - parse nroff-formatted manpages and return a DOM tree

 use Parse::Man::DOM;
 my $parser = Parse::Man::DOM->new;
 my $document = $parser->from_file( "my_manpage.1" );
 print "The manpage name is", $document->meta( "name" ), "\n";

This subclass of Parse::Man returns an object tree representing the parsed content of the input file. The returned result will be an object of the "Parse::Man::DOM::Document" class, which itself will contain other objects nested within it.

Represents the document as a whole.

   $meta = $document->meta( $key )

Returns a "Parse::Man::DOM::Metadata" object for the named item of metadata.

  • name

    The page name given to the ".TH" directive.

  • section

    The section number given to the ".TH" directive.

   @paras = $document->paras

Returns a list of "Parse::Man::DOM::Heading" or "Parse::Man::DOM::Para" or subclass objects, containing the actual page content.

Represents a single item of metadata about the page.

   $name = $metadata->name

The string name of the metadata

   $value = $metadata->value

The string value of the metadata

Represents the contents of a ".SH" or ".SS" heading

   $level = $heading->level

The heading level number; 1 for ".SH", 2 for ".SS"

   $text = $heading->text

The plain text string of the heading title

Represents a paragraph of formatted text content. Will be one of the following subclasses.

   $filling = $para->filling

Returns true if filling (".fi") is in effect, or false if no-filling (".nf") is in effect.

   $chunklist = $para->body

Returns a "Parse::Man::DOM::Chunklist" to represent the actual content of the paragraph.

   $indent = $para->indent

Returns the indentation size in column count, if defined.

Represent a plain (".P" or ".PP") paragraph.

   $type = $para->type

Returns "plain".

Represents a term paragraph (".TP").

   $type = $para->type

Returns "term".

   $chunklist = $para->term

Returns a "Parse::Man::DOM::Chunklist" for the defined term name.

   $chunklist = $para->definition

Returns a "Parse::Man::DOM::Chunklist" for the defined term definition.

Represents an indented paragraph (".IP").

   $type = $para->type

Returns "indent".

   $marker = $para->marker

Returns the indentation marker text, if defined.

Represents an example paragraph (".EX" / ".EE").

   $type = $para->type

Returns "example".

Contains a list of "Parse::Man::DOM::Chunk" objects to represent paragraph content.

   @chunks = $chunklist->chunks

Returns a list of "Parse::Man::DOM::Chunk" objects.

Represents a chunk of text with a particular format applied.

   $text = $chunk->text

The plain string value of the text for this chunk.

   $font = $chunk->font

The font name in effect for this chunk. One of "R", "B", "I" or "SM".

   $size = $chunk->size

The size of this chunk, relative to the paragraph base of 0.

Paul Evans <leonerd@leonerd.org.uk>

2023-10-24 perl v5.36.0