-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes GH-35. Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com> Reviewed-by: Junyoung Choi <fluke8259@gmail.com> Reviewed-by: Titus Wormer <tituswormer@gmail.com>
- Loading branch information
1 parent
35d2f90
commit 38bdb01
Showing
17 changed files
with
204 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
coverage | ||
rehype.js | ||
rehype.min.js | ||
*.html | ||
*.json | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// TypeScript Version: 3.5 | ||
import {Parser, Plugin} from 'unified' | ||
import {Node, Parent} from 'unist' | ||
import {HastUtilFromParse5Options} from 'hast-util-from-parse5' | ||
|
||
declare namespace rehypeParse { | ||
interface Parse extends Plugin<[RehypeParseOptions?]> { | ||
Parser: Parser | ||
} | ||
|
||
interface RehypeParseOptions | ||
extends Pick<HastUtilFromParse5Options, 'space' | 'verbose'> { | ||
/** | ||
* Specify whether to parse a fragment, instead of a complete document. | ||
* In document mode, unopened `html`, `head`, and `body` elements are opened in | ||
* just the right places. | ||
* | ||
* @default false | ||
*/ | ||
fragment?: boolean | ||
|
||
/** | ||
* > ⚠️ Parse errors are currently being added to HTML. | ||
* > Not all errors emitted by parse5 (or rehype-parse) are specced yet. | ||
* > Some documentation may still be missing. | ||
* | ||
* Emit parse errors while parsing on the [vfile](https://github.com/vfile/vfile) | ||
* | ||
* Setting this to true starts emitting | ||
* [HTML parse errors](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors). | ||
* | ||
* Specific rules can be turned off by setting them to `false` (or `0`). | ||
* The default, when `emitParseErrors: true`, is `true` (or `1`), and means that | ||
* rules emit as warnings. | ||
* Rules can also be configured with `2`, to turn them into fatal errors. | ||
* | ||
* @default false | ||
*/ | ||
emitParseErrors?: boolean | ||
} | ||
|
||
type Visitor = (node: Node, parent?: Parent) => string | ||
} | ||
|
||
declare const rehypeParse: rehypeParse.Parse | ||
|
||
export = rehypeParse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unified = require('unified') | ||
import parse = require('rehype-parse') | ||
|
||
unified().use(parse) | ||
|
||
unified().use(parse, {}) | ||
|
||
unified().use(parse, {fragment: true}) | ||
|
||
unified().use(parse, {space: 'html'}) | ||
unified().use(parse, {space: 'svg'}) | ||
|
||
unified().use(parse, {emitParseErrors: true}) | ||
|
||
unified().use(parse, {verbose: true}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"rehype-parse": ["index.d.ts"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"no-redundant-jsdoc": false, | ||
"semicolon": false, | ||
"whitespace": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// TypeScript Version: 3.5 | ||
import {Compiler, Processor, Plugin} from 'unified' | ||
import {Node, Parent} from 'unist' | ||
import {HastUtilToHtmlOptions} from 'hast-util-to-html' | ||
|
||
declare class RehypeCompiler implements Compiler { | ||
compile(): string | ||
visitors: { | ||
[key: string]: rehypeStringify.Visitor | ||
} | ||
} | ||
|
||
declare namespace rehypeStringify { | ||
interface Stringify extends Plugin<[HastUtilToHtmlOptions?]> { | ||
Compiler: typeof RehypeCompiler | ||
(this: Processor, options?: HastUtilToHtmlOptions): void | ||
} | ||
|
||
type RehypeStringifyOptions = HastUtilToHtmlOptions | ||
|
||
type Compiler = RehypeCompiler | ||
|
||
type Visitor = (node: Node, parent?: Parent) => string | ||
} | ||
|
||
declare const rehypeStringify: rehypeStringify.Stringify | ||
|
||
export = rehypeStringify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import unified = require('unified') | ||
import stringify = require('rehype-stringify') | ||
|
||
unified().use(stringify) | ||
|
||
unified().use(stringify, {}) | ||
|
||
unified().use(stringify, { | ||
upperDoctype: true | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"rehype-stringify": ["index.d.ts"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"semicolon": false, | ||
"whitespace": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// TypeScript Version: 3.5 | ||
|
||
import {Processor} from 'unified' | ||
import {RehypeParseOptions} from 'rehype-parse' | ||
import {RehypeStringifyOptions} from 'rehype-stringify' | ||
|
||
declare namespace rehype { | ||
type RehypeOptions = RehypeStringifyOptions & RehypeParseOptions | ||
} | ||
|
||
declare function rehype(): Processor<rehype.RehypeOptions> | ||
|
||
export = rehype |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import rehype = require('rehype') | ||
|
||
interface PluginOptions { | ||
example: boolean | ||
} | ||
|
||
const plugin = (options?: PluginOptions) => {} | ||
|
||
rehype().use(plugin) | ||
rehype().use(plugin, {example: true}) | ||
rehype().use({settings: {fragment: true}}) | ||
rehype().use({settings: {upperDoctype: true}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"rehype": ["index.d.ts"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"max-line-length": false, | ||
"no-redundant-jsdoc": false, | ||
"no-void-expression": false, | ||
"only-arrow-functions": false, | ||
"semicolon": false, | ||
"unified-signatures": false, | ||
"whitespace": false, | ||
"interface-over-type-literal": false, | ||
"no-unnecessary-generics": false, | ||
"strict-export-declare-modifiers": false | ||
} | ||
} |