Skip to content

Main content

Markdown Heading Closing Hash Boundary Tool

Compute markdown heading closing hash boundary from explicit bounded inputs.

Loading tool…

Description

Remove a trailing hash run only when preceded by whitespace, returning trimmed content and closingHashes.

Markdown markers are interpreted in block and inline context, and extensions can add further syntax. Heading delimiters, backslash escapes, and task checkboxes each have local boundaries. A single-line or single-token recognizer does not necessarily reproduce a complete renderer.

Remove a trailing hash run only when preceded by whitespace, returning trimmed content and closingHashes.

When to use this tool

Use Markdown Heading Closing Hash Boundary when you need this particular heading, escape, or task-marker recognition step on supplied text.

How to use the tool and how it works

  1. Enter line. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read content, closingHashes. Use the output convention below.

Require an ATX-like heading opener of one through six hashes after at most three leading spaces and a space/tab boundary or end of line. Remove a trailing hash run only when preceded by whitespace, returning trimmed content and closingHashes.1

An optional ATX closing hash run needs a whitespace boundary. Complete heading parsing also considers escapes and block context beyond this tool's single-line pattern.2

Input fieldMeaning and unitsAccepted input
lineOne supplied line under the stated newline policy.Required. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
contentContentRequired. Text; maximum UTF-16 length 8192.
closingHashesLength of removed closing run; zero if none matched.Required. Safe integer.
json
{
  "input": {
    "line": "## Heading ##"
  },
  "output": {
    "content": "Heading",
    "closingHashes": 2
  }
}

Limitations and assumptions

  • The calculation recognizes one line under its explicit pattern rather than parsing block context or escape semantics. A hash adjacent to content remains content, and no full Markdown conformance is claimed.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Use a renderer or parser for the intended Markdown version and extensions when surrounding context matters. A local marker match is not full document conformance.

References

  1. Calculation and input contract: parse/markdown-heading-closing-hash-boundary — tool.io

  2. CommonMark 0.31.2: ATX Headings — John MacFarlane

Similar or alternative tools