Skip to main content
Version: 3.x.x 🚧


Npm VersionNpm DownloadNpm LicenseModule formats: cjs, esmNode.js VersionTested with JestCode Style: prettier

github flavor markdown spec

Hard line breaks

A line break (not in a code span or HTML tag) that is preceded by two or more spaces and does not occur at the end of a block is parsed as a hard line break (rendered in HTML as a <br /> tag).

Soft line breaks

A regular line break (not in a code span or HTML tag) that is not preceded by two or more spaces or a backslash is parsed as a [softbreak]gfm-softbreak. (A softbreak may be rendered in HTML either as a line ending or as a space. The result will be the same in browsers. In the examples here, a line ending will be used.)


npm install --save @yozora/tokenizer-break



@yozora/tokenizer-break has been integrated into @yozora/parser / @yozora/parser-gfm-ex / @yozora/parser-gfm, so you can use YozoraParser / GfmExParser / GfmParser directly.

import YozoraParser from '@yozora/parser'

const parser = new YozoraParser()

// parse source markdown content




  • name: The unique name of the tokenizer, used to bind the token it generates, to determine the tokenizer that should be called in each life cycle of the token in the entire matching / parsing phase.

  • priority: Priority of the tokenizer, determine the order of processing, high priority priority execution. interruptable. In addition, in the match-block stage, a high-priority tokenizer can interrupt the matching process of a low-priority tokenizer.

    Exception: Delimiters of type full are always processed before other type delimiters.


@yozora/tokenizer-break produce Break type nodes. See @yozora/ast for full base types.

import type { Node } from '@yozora/ast'

export const BreakType = 'break'
export type BreakType = typeof BreakType

* Break represents a line break, such as in poems or addresses.
* @see
* @see
* @see
export type Break = Node<BreakType>

Live Examples

Hard line breaks

  • Basic.

  • For a more visible alternative, a backslash before the line ending may be used instead of two spaces.

  • More than two spaces can be used.

  • Leading spaces at the beginning of the next line are ignored.

  • Line breaks can occur inside emphasis, links, and other constructs that allow inline content.

  • Line breaks do not occur inside code spans or or HTML tags.

  • Hard line breaks are for separating inline content within a block. Neither syntax for hard line breaks works at the end of a paragraph or other block element.


Soft line breaks

  • Basic.

  • Spaces at the end of the line and beginning of the next line are removed.