Skip to main content
Markdown Halstead measures token vocabulary and volume using Markdown-native operators and operands instead of code operators. It uses the same shape as source-code Halstead but with a documentation-specific operator/operand taxonomy.

Operators

  • Heading markers by level (#, ##, …).
  • List markers (-, *, 1., …).
  • Table delimiters (|, alignment markers).
  • Link / image operators ([…](…), ![…](…)).
  • Code-fence openers by language (```python).
  • Inline code, blockquote (>), math delimiters ($…$, $$…$$).
  • Emphasis markers (*, _, **).
  • Footnote operators.
  • Raw-HTML / MDX / directive operators.
  • Punctuation classes.
  • Diagram DSL statement classes.
  • Embedded-code operators.

Operands

  • Word-like tokens.
  • Numeric / version tokens.
  • Identifier-like tokens.
  • Path-like tokens.
  • Link destinations.
  • Table headers.
  • Image destinations / alt hashes.
  • Code identifiers from embedded analyzers.
  • Diagram node / edge labels.
  • Math symbols and commands.

Formulas

Same shape as source-code Halstead:

Embedded-code adjustment

Embedded analyzers contribute:
per code block. Raw embedded volume is square-rooted because it can otherwise dwarf document-level signals; cognitive complexity stays linear because a hard example genuinely requires review.

References

  • Halstead, M. H. (1977). Elements of Software Science. Elsevier — the operator/operand model this metric ports to Markdown’s token taxonomy. OSTI record.
  • Kearney, J. K., et al. Software Complexity Measurement — MIT lecture notes summarizing the Halstead operator/operand formulation. PDF (MIT OCW 16.355).

See also