Skip to main content
Version: 2.x.x


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

github flavor markdown spec

Syntax for images is like the syntax for links, with one difference. Instead of link text, we have an image description. The rules for this are the same as for link text, except that

  • a) an image description starts with ![ rather than [, and
  • b) an image description may contain links. An image description has inline elements as its contents. When an image is rendered to HTML, this is standardly used as the image’s alt attribute.


npm install --save @yozora/tokenizer-image-reference



@yozora/tokenizer-image-reference 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

[foo]: /url "title"


  • 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-image-reference produce ImageReference type nodes. See @yozora/ast for full base types.

import type {
} from '@yozora/ast'

export const ImageReferenceType = 'imageReference'
export type ImageReferenceType = typeof ImageReferenceType

* ImageReference represents an image through association, or its original
* source if there is no association.
* @see
* @see
export interface ImageReference extends
Alternative {}

Live Examples

Full style

  • Basic.


Collapsed style

  • Basic.

  • The labels are case-insensitive.

  • As with reference links, whitespace is not allowed between the two sets of brackets.


Shortcut styled

  • Basic.

  • Note that link labels cannot contain unescaped brackets.

  • The link labels are case-insensitive。

  • If you just want a literal ! followed by bracketed text, you can backslash-escape the opening [.

  • If you want a link after a literal !, backslash-escape the !.