@@ -18,7 +18,7 @@ export function Marked(props: { children: string }) {
1818 * Block-Level Grammar
1919 */
2020
21- var block = {
21+ const block = {
2222 newline : / ^ \n + / ,
2323 code : / ^ ( { 4 } [ ^ \n ] + \n * ) + / ,
2424 fences : noop ,
@@ -124,7 +124,7 @@ Lexer.rules = block
124124 */
125125
126126Lexer . lex = function ( src , options ) {
127- var lexer = new Lexer ( options )
127+ const lexer = new Lexer ( options )
128128 return lexer . lex ( src )
129129}
130130
@@ -147,16 +147,8 @@ Lexer.prototype.lex = function (src) {
147147 */
148148
149149Lexer . prototype . token = function ( src , top ) {
150- var src = src . replace ( / ^ + $ / gm, "" ) ,
151- next ,
152- loose ,
153- cap ,
154- bull ,
155- b ,
156- item ,
157- space ,
158- i ,
159- l
150+ src = src . replace ( / ^ + $ / gm, "" )
151+ let next , loose , cap , bull , b , item , space , i , l
160152
161153 while ( src ) {
162154 // newline
@@ -437,7 +429,7 @@ Lexer.prototype.token = function (src, top) {
437429 * Inline-Level Grammar
438430 */
439431
440- var inline = {
432+ const inline = {
441433 escape : / ^ \\ ( [ \\ ` * { } \[ \] ( ) # + \- . ! _ > ] ) / ,
442434 autolink : / ^ < ( [ ^ > ] + ( @ | : \/ ) [ ^ > ] + ) > / ,
443435 url : noop ,
@@ -533,7 +525,7 @@ InlineLexer.rules = inline
533525 */
534526
535527InlineLexer . output = function ( src , links , options ) {
536- var inline = new InlineLexer ( links , options )
528+ const inline = new InlineLexer ( links , options )
537529 return inline . output ( src )
538530}
539531
@@ -542,11 +534,8 @@ InlineLexer.output = function (src, links, options) {
542534 */
543535
544536InlineLexer . prototype . output = function ( src ) {
545- var out = [ ] ,
546- link ,
547- text ,
548- href ,
549- cap
537+ const out = [ ]
538+ let link , text , href , cap
550539
551540 while ( src ) {
552541 // escape
@@ -686,7 +675,7 @@ InlineLexer.prototype.output = function (src) {
686675InlineLexer . prototype . sanitizeUrl = function ( url ) {
687676 if ( this . options . sanitize ) {
688677 try {
689- var prot = decodeURIComponent ( url )
678+ const prot = decodeURIComponent ( url )
690679 . replace ( / [ ^ A - Z a - z 0 - 9 : ] / g, "" )
691680 . toLowerCase ( )
692681 if ( prot . indexOf ( "javascript:" ) === 0 ) {
@@ -705,7 +694,7 @@ InlineLexer.prototype.sanitizeUrl = function (url) {
705694
706695InlineLexer . prototype . outputLink = function ( cap , link ) {
707696 if ( cap [ 0 ] [ 0 ] !== "!" ) {
708- var shouldOpenInNewWindow =
697+ const shouldOpenInNewWindow =
709698 link . href . charAt ( 0 ) !== "/" && link . href . charAt ( 0 ) !== "#"
710699
711700 return createElement (
@@ -762,7 +751,7 @@ function Parser(options) {
762751 */
763752
764753Parser . parse = function ( src , options ) {
765- var parser = new Parser ( options )
754+ const parser = new Parser ( options )
766755 return parser . parse ( src )
767756}
768757
@@ -774,7 +763,7 @@ Parser.prototype.parse = function (src) {
774763 this . inline = new InlineLexer ( src . links , this . options )
775764 this . tokens = src . reverse ( )
776765
777- var out = [ ]
766+ const out = [ ]
778767 while ( this . next ( ) ) {
779768 out . push ( this . tok ( ) )
780769 }
@@ -803,7 +792,7 @@ Parser.prototype.peek = function () {
803792 */
804793
805794Parser . prototype . parseText = function ( ) {
806- var body = this . token . text
795+ let body = this . token . text
807796
808797 while ( this . peek ( ) . type === "text" ) {
809798 body += "\n" + this . next ( ) . text
@@ -820,18 +809,18 @@ Parser.prototype.tok = function () {
820809 switch ( this . token . type ) {
821810 case "code" : {
822811 if ( this . token . lang === "graphql" ) {
823- var lines = this . token . text . split ( "\n" )
824- var firstLine = lines . shift ( ) . match ( / ^ \s * # \s * ( { .* } ) $ / )
812+ const lines = this . token . text . split ( "\n" )
813+ const firstLine = lines . shift ( ) . match ( / ^ \s * # \s * ( { .* } ) $ / )
825814 if ( firstLine ) {
826- var metaData
815+ let metaData
827816 try {
828817 metaData = JSON . parse ( firstLine [ 1 ] )
829818 } catch ( e ) {
830819 console . error ( "Invalid Metadata JSON:" , firstLine [ 1 ] )
831820 }
832821 if ( metaData ) {
833- var query = lines . join ( "\n" )
834- var variables = metaData . variables
822+ const query = lines . join ( "\n" )
823+ const variables = metaData . variables
835824 ? JSON . stringify ( metaData . variables , null , 2 )
836825 : ""
837826 const schemaMap = {
@@ -871,7 +860,7 @@ function noop() {}
871860noop . exec = noop
872861
873862function merge ( obj ) {
874- var i = 1 ,
863+ let i = 1 ,
875864 target ,
876865 key
877866
@@ -900,8 +889,8 @@ function marked(src, opt, callback) {
900889
901890 if ( opt ) opt = merge ( { } , marked . defaults , opt )
902891
903- var highlight = opt . highlight ,
904- tokens ,
892+ const highlight = opt . highlight
893+ let tokens ,
905894 pending ,
906895 i = 0
907896
@@ -913,8 +902,8 @@ function marked(src, opt, callback) {
913902
914903 pending = tokens . length
915904
916- var done = function ( hi ) {
917- var out , err
905+ const done = function ( hi ) {
906+ let out , err
918907
919908 if ( hi !== true ) {
920909 delete opt . highlight
0 commit comments