A minimalist markdown-it
plugin for parsing video/audio references inside
markdown image syntax as <video>
/ <audio>
tags.
Methods
(static) guessMediaType(url) → {String}
Guess the media type represented by a URL based on the file extension, if any
Parameters:
Name | Type | Description |
---|---|---|
url |
String | any valid URL |
Returns:
a type identifier: 'image' (default for all unrecognized URLs), 'audio' or 'video'
- Type
- String
(static) html5Media(md, optionsopt)
The main plugin function, exported as module.exports
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
md |
MarkdownIt | instance, automatically passed by md.use |
|||||||||||||||||||||
options |
Object |
<optional> |
configuration Properties
|
(static) renderMedia(tokens, idx, options, env, md) → {String}
Render tokens of the video/audio type to HTML5 tags
Parameters:
Name | Type | Description |
---|---|---|
tokens |
Object | token stream |
idx |
Number | which token are we rendering |
options |
Object | Markdown-It options, including this plugin's settings |
env |
Object | Markdown-It environment, potentially including language setting |
md |
MarkdownIt | instance used for utilities access |
Returns:
rendered token
- Type
- String
(static) tokenizeImagesAndMedia(state, silent, md) → {Boolean}
A fork of the built-in image tokenizer which guesses video/audio files based on their extension, and tokenizes them accordingly.
Parameters:
Name | Type | Description |
---|---|---|
state |
Object | Markdown-It state |
silent |
Boolean | if true, only validate, don't tokenize |
md |
MarkdownIt | instance of Markdown-It used for utility functions |
Returns:
- Type
- Boolean
(static) translate(language, messageKey, messageParams) → {String}
You can override this function using options.translateFn.
Parameters:
Name | Type | Description |
---|---|---|
language |
String | a language code, typically an ISO 639-[1-3] code. |
messageKey |
String | an identifier for the message, typically a short descriptive text |
messageParams |
Array.<String> | Strings to be substituted into the message using some pattern, e.g., %s or %1$s, %2$s. By default we only use a simple %s pattern. |
Returns:
the translation to use
- Type
- String