@khanacademy/simple-markdown 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -18,11 +18,7 @@
18
18
  * the wonderful [marked.js](https://github.com/chjj/marked)
19
19
  */
20
20
  import * as React from "react";
21
- type Capture = (Array<string> & {
22
- index: number;
23
- }) | (Array<string> & {
24
- index?: number;
25
- });
21
+ import type { Capture, MatchFunction, State } from "./troublesome-types";
26
22
  type Attr = string | number | boolean | null | undefined;
27
23
  type SingleASTNode = {
28
24
  type: string;
@@ -32,16 +28,8 @@ type UnTypedASTNode = {
32
28
  [key: string]: any;
33
29
  };
34
30
  type ASTNode = SingleASTNode | Array<SingleASTNode>;
35
- type State = {
36
- key?: string | number | undefined;
37
- inline?: boolean | null | undefined;
38
- [key: string]: any;
39
- };
40
31
  type ReactElement = React.ReactElement<any>;
41
32
  type ReactElements = React.ReactNode;
42
- type MatchFunction = {
43
- regex?: RegExp;
44
- } & ((source: string, state: State, prevCapture: string) => Capture | null | undefined);
45
33
  type Parser = (source: string, state?: State | null | undefined) => Array<SingleASTNode>;
46
34
  type ParseFunction = (capture: Capture, nestedParse: Parser, state: State) => UnTypedASTNode | ASTNode;
47
35
  type SingleNodeParseFunction = (capture: Capture, nestedParse: Parser, state: State) => UnTypedASTNode;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@
27
27
  // reuse defaultRules built-ins. So we make some stronger guarantess when
28
28
  // we can:
29
29
 
30
- // End Flow Definitions
30
+ // End TypeScript Definitions
31
31
 
32
32
  var CR_NEWLINE_R = /\r\n?/g;
33
33
  var TAB_R = /\t/g;
@@ -280,9 +280,7 @@ var htmlTag = function (tagName, content, attributes, isClosed) {
280
280
  for (var attr in attributes) {
281
281
  var attribute = attributes[attr];
282
282
  // Removes falsey attributes
283
- if (
284
- // $FlowFixMe
285
- Object.prototype.hasOwnProperty.call(attributes, attr) && attribute) {
283
+ if (Object.prototype.hasOwnProperty.call(attributes, attr) && attribute) {
286
284
  attributeString += " " + sanitizeText(attr) + '="' + sanitizeText(attribute) + '"';
287
285
  }
288
286
  }
@@ -670,7 +668,6 @@ var defaultRules = {
670
668
  },
671
669
  list: {
672
670
  order: currOrder++,
673
- // $FlowFixMe
674
671
  match: function (source, state) {
675
672
  // We only want to break into a list if we are at the start of a
676
673
  // line. This is to avoid parsing "hi * there" with "* there"
@@ -947,7 +944,6 @@ var defaultRules = {
947
944
  },
948
945
  tableSeparator: {
949
946
  order: currOrder++,
950
- // $FlowFixMe
951
947
  match: function (source, state) {
952
948
  if (!state.inTable) {
953
949
  return null;
@@ -1247,9 +1243,7 @@ var defaultRules = {
1247
1243
  };
1248
1244
 
1249
1245
  /** (deprecated) */
1250
- var ruleOutput = function (
1251
- // $FlowFixMe
1252
- rules, property) {
1246
+ var ruleOutput = function (rules, property) {
1253
1247
  if (!property && typeof console !== "undefined") {
1254
1248
  console.warn("simple-markdown ruleOutput should take 'react' or " + "'html' as the second argument.");
1255
1249
  }
@@ -1377,9 +1371,7 @@ var markdownToHtml = function (source, state) {
1377
1371
  var ReactMarkdown = function (props) {
1378
1372
  var divProps = {};
1379
1373
  for (var prop in props) {
1380
- if (prop !== "source" &&
1381
- // $FlowFixMe
1382
- Object.prototype.hasOwnProperty.call(props, prop)) {
1374
+ if (prop !== "source" && Object.prototype.hasOwnProperty.call(props, prop)) {
1383
1375
  divProps[prop] = props[prop];
1384
1376
  }
1385
1377
  }
@@ -5,19 +5,7 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type Capture =
9
- | {|
10
- ...Array<string>,
11
- ...{|
12
- index: number,
13
- |},
14
- |}
15
- | {|
16
- ...Array<string>,
17
- ...{|
18
- index?: number,
19
- |},
20
- |};
8
+ import type { Capture, MatchFunction, State } from "./troublesome-types";
21
9
  declare type Attr = string | number | boolean | null | void;
22
10
  declare type SingleASTNode = {
23
11
  type: string,
@@ -27,23 +15,8 @@ declare type UnTypedASTNode = {
27
15
  [key: string]: any,
28
16
  };
29
17
  declare type ASTNode = SingleASTNode | Array<SingleASTNode>;
30
- declare type State = {
31
- key?: string | number | void,
32
- inline?: boolean | null | void,
33
- [key: string]: any,
34
- };
35
18
  declare type ReactElement = React.Element<any>;
36
19
  declare type ReactElements = React.Node;
37
- declare type MatchFunction = {|
38
- ...{|
39
- regex?: RegExp,
40
- |},
41
- ...(
42
- source: string,
43
- state: State,
44
- prevCapture: string
45
- ) => Capture | null | void,
46
- |};
47
20
  declare type Parser = (
48
21
  source: string,
49
22
  state?: State | null | void