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

`)
import YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`

`)
import GfmParser from '@yozora/parser-gfm'
const parser = new GfmParser()
// parse source markdown content
parser.parse(`

`)
import GfmExParser from '@yozora/parser-gfm-ex'
const parser = new GfmExParser()
// parse source markdown content
parser.parse(`

`)
Options
Name | Type | Required | Default |
---|---|---|---|
name | string | false | "@yozora/tokenizer-image" |
priority | number | false | TokenizerPriority.LINKS |
-
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 thematch-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.
Types
@yozora/tokenizer-image produce Image type nodes. See @yozora/ast for full base types.
import type { YastAlternative, YastNode, YastResource } from '@yozora/ast'
export const ImageType = 'image'
export type ImageType = typeof ImageType
/**
* Image represents an image.
* @see https://github.com/syntax-tree/mdast#image
* @see https://github.github.com/gfm/#images
*/
export interface Image extends
YastNode<ImageType>,
YastResource,
YastAlternative {}
Live Examples
-
Basic.
-
Though this spec is concerned with parsing, not rendering, it is recommended that in rendering to HTML, only the plain string content of the image description be used. Note that in the above example, the alt attribute’s value is
foo bar
, notfoo [bar](/url)
orfoo <a href="/url">bar</a>
. Only the plain string content is rendered, without formatting.