HookContext class

Contextual information passed to hook functions during parsing.

HookContext provides location and styling information about the element being processed. Use it to make context-sensitive decisions in your hooks.

Example

final hooks = DocxToMarkdownHooks(
  transformBlock: (block, ctx) {
    if (ctx.styleId == 'Draft') {
      return null; // Drop paragraphs with "Draft" style
    }
    return block;
  },
);

See also:

Constructors

HookContext({String part = '', String path = '', String? styleId, int? listLevel, Map<String, Object?> meta = const {}, String? location})
Creates a hook context with optional location and style information.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
listLevel int?
The list nesting level (0-based) when processing a list item.
final
location String
A formatted string suitable for logging: "part::path".
no setter
meta Map<String, Object?>
Additional metadata for future expansion.
final
part String
The OOXML part being processed, e.g., word/document.xml.
final
path String
XPath-like location within the part, e.g., body/p[12]/r[3].
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
styleId String?
The Word paragraph style ID when processing a paragraph.
final

Methods

child(String segment, {String? styleId, int? listLevel, Map<String, Object?>? meta}) HookContext
Creates a child context by appending a segment to the current path.
copyWith({String? part, String? path, String? styleId, int? listLevel, Map<String, Object?>? meta, String? location}) HookContext
Creates a copy of this context with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited