@stoplight/markdown
Useful functions when working with Markdown. Leverages the Unified / Remark ecosystem under the hood.
Installation
Supported in modern browsers and node.
yarn add @stoplight/markdown
Usage
Example parseWithPointers
Note: Unlike most of the other functions, parseWithPointers is not exported from root. You must import by name.
import { parseWithPointers } from "@stoplight/markdown/parseWithPointers" ;
const result = parseWithPointers("**markdown**" );
console .log(result.data);
Contributing
Clone repo.
Create / checkout feature/{name}
, chore/{name}
, or fix/{name}
branch.
Install deps: yarn
.
Make your changes.
Run tests: yarn test.prod
.
Stage relevant files to git.
Commit: yarn commit
. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit
creates this format for you, or you can put it together manually and then do a regular git commit
.
Push: git push
.
Open PR targeting the develop
branch.
Type aliases
AlignType
AlignType: "left" | "right" | "center" | null
AnnotationType
AnnotationType: "tab" | "tab-end"
ElementTagNameType
ElementTagNameType: "div" | "span"
MarkdownParserResult
MarkdownParserResult: IParserResult < Parent , Parent >
PropertyPath
PropertyPath: PropertyKey | PropertyKey []
ReferenceType
ReferenceType: "shortcut" | "collapsed" | "full"
ThemeType
ThemeType: "info" | "warning" | "danger" | "success"
Functions
default
default( this: Processor ) : void
Const getJsonPathForNode
getJsonPathForNode( root: Parent , node: Node ) : JsonPath | void
Parameters
Returns JsonPath
|
void
Const getJsonPathForPosition
getJsonPathForPosition( __namedParameters: object , position: IPosition ) : ( string | number ) []
Parameters
__namedParameters: object
position: IPosition
Returns ( string | number ) []
Const getLocationForJsonPath
getLocationForJsonPath( __namedParameters: object , path: JsonPath ) : undefined | object
Parameters
__namedParameters: object
path: JsonPath
Returns undefined
|
object
Const getProperty
getProperty( propName: string , element: undefined | string , data: Unist.Node ) : undefined | string | void
Parameters
propName: string
Optional element: undefined | string
Optional data: Unist.Node
Returns undefined
|
string
|
void
Const getSummary
getSummary( data: Unist.Node , opts?: IGetSummaryOpts ) : undefined | string | void
Parameters
Optional data: Unist.Node
Returns undefined
|
string
|
void
Const getTags
getTags( data: Unist.Node ) : string []
Parameters
Optional data: Unist.Node
Returns string []
Const getTitle
getTitle( data: Unist.Node ) : undefined | string | void
Parameters
Optional data: Unist.Node
Returns undefined
|
string
|
void
Const parse
parse( input: string , opts?: Partial < RemarkParseOptions > , processor?: Processor ) : Node
Parameters
input: string
Default value opts: Partial < RemarkParseOptions > = defaultOpts
Default value processor: Processor = defaultProcessor
Returns Node
Const parseWithPointers
parseWithPointers( value: string , opts: Partial < RemarkParseOptions > , processor: unified.Processor ) : MarkdownParserResult
Parameters
value: string
Optional opts: Partial < RemarkParseOptions >
Optional processor: unified.Processor
Const stringify
stringify( tree: Node , opts?: Partial < RemarkStringifyOptions > , processor?: Processor ) : string
Parameters
tree: Node
Default value opts: Partial < RemarkStringifyOptions > = defaultOpts
Default value processor: Processor = defaultProcessor
Returns string
Legend
Module
Object literal
Variable
Function
Function with type parameter
Index signature
Type alias
Enumeration
Enumeration member
Property
Method
Interface
Interface with type parameter
Constructor
Property
Method
Index signature
Class
Class with type parameter
Constructor
Property
Method
Accessor
Index signature
Inherited constructor
Inherited property
Inherited method
Inherited accessor
Protected property
Protected method
Protected accessor
Private property
Private method
Private accessor
Static property
Static method