safe-mdx 1.0.1 → 1.0.3
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/parse.d.ts +10 -0
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +1 -1
- package/dist/parse.js.map +1 -1
- package/dist/safe-mdx.d.ts.map +1 -1
- package/dist/safe-mdx.js +2 -290
- package/dist/safe-mdx.js.map +1 -1
- package/dist/safe-mdx.test.js +46 -59
- package/dist/safe-mdx.test.js.map +1 -1
- package/package.json +1 -1
- package/src/parse.ts +2 -2
- package/src/safe-mdx.test.tsx +46 -59
- package/src/safe-mdx.tsx +2 -294
package/src/safe-mdx.tsx
CHANGED
|
@@ -59,7 +59,7 @@ export class MdastToJsx {
|
|
|
59
59
|
|
|
60
60
|
constructor({
|
|
61
61
|
markdown: code = '',
|
|
62
|
-
mdast
|
|
62
|
+
mdast,
|
|
63
63
|
components = {} as ComponentsMap,
|
|
64
64
|
renderNode,
|
|
65
65
|
}: {
|
|
@@ -262,18 +262,7 @@ export class MdastToJsx {
|
|
|
262
262
|
)
|
|
263
263
|
|
|
264
264
|
if (language) {
|
|
265
|
-
|
|
266
|
-
supportedLanguagesSet.has(
|
|
267
|
-
language as (typeof supportedLanguages)[number],
|
|
268
|
-
)
|
|
269
|
-
) {
|
|
270
|
-
return codeBlock(`language-${language}`)
|
|
271
|
-
} else {
|
|
272
|
-
this.errors.push({
|
|
273
|
-
message: `Unsupported language ${language}`,
|
|
274
|
-
})
|
|
275
|
-
return codeBlock()
|
|
276
|
-
}
|
|
265
|
+
return codeBlock(`language-${language}`)
|
|
277
266
|
}
|
|
278
267
|
return codeBlock()
|
|
279
268
|
}
|
|
@@ -657,287 +646,6 @@ const nativeTags = [
|
|
|
657
646
|
'time',
|
|
658
647
|
] as const
|
|
659
648
|
|
|
660
|
-
const supportedLanguages = [
|
|
661
|
-
'abap',
|
|
662
|
-
'abnf',
|
|
663
|
-
'actionscript',
|
|
664
|
-
'ada',
|
|
665
|
-
'agda',
|
|
666
|
-
'al',
|
|
667
|
-
'antlr4',
|
|
668
|
-
'apacheconf',
|
|
669
|
-
'apex',
|
|
670
|
-
'apl',
|
|
671
|
-
'applescript',
|
|
672
|
-
'aql',
|
|
673
|
-
'arduino',
|
|
674
|
-
'arff',
|
|
675
|
-
'asciidoc',
|
|
676
|
-
'asm6502',
|
|
677
|
-
'asmatmel',
|
|
678
|
-
'aspnet',
|
|
679
|
-
'autohotkey',
|
|
680
|
-
'autoit',
|
|
681
|
-
'avisynth',
|
|
682
|
-
'avro-idl',
|
|
683
|
-
'bash',
|
|
684
|
-
'basic',
|
|
685
|
-
'batch',
|
|
686
|
-
'bbcode',
|
|
687
|
-
'bicep',
|
|
688
|
-
'birb',
|
|
689
|
-
'bison',
|
|
690
|
-
'bnf',
|
|
691
|
-
'brainfuck',
|
|
692
|
-
'brightscript',
|
|
693
|
-
'bro',
|
|
694
|
-
'bsl',
|
|
695
|
-
'c',
|
|
696
|
-
'cfscript',
|
|
697
|
-
'chaiscript',
|
|
698
|
-
'cil',
|
|
699
|
-
'clike',
|
|
700
|
-
'clojure',
|
|
701
|
-
'cmake',
|
|
702
|
-
'cobol',
|
|
703
|
-
'coffeescript',
|
|
704
|
-
'concurnas',
|
|
705
|
-
'coq',
|
|
706
|
-
'cpp',
|
|
707
|
-
'crystal',
|
|
708
|
-
'csharp',
|
|
709
|
-
'cshtml',
|
|
710
|
-
'csp',
|
|
711
|
-
'css-extras',
|
|
712
|
-
'css',
|
|
713
|
-
'csv',
|
|
714
|
-
'cypher',
|
|
715
|
-
'd',
|
|
716
|
-
'dart',
|
|
717
|
-
'dataweave',
|
|
718
|
-
'dax',
|
|
719
|
-
'dhall',
|
|
720
|
-
'diff',
|
|
721
|
-
'django',
|
|
722
|
-
'dns-zone-file',
|
|
723
|
-
'docker',
|
|
724
|
-
'dot',
|
|
725
|
-
'ebnf',
|
|
726
|
-
'editorconfig',
|
|
727
|
-
'eiffel',
|
|
728
|
-
'ejs',
|
|
729
|
-
'elixir',
|
|
730
|
-
'elm',
|
|
731
|
-
'erb',
|
|
732
|
-
'erlang',
|
|
733
|
-
'etlua',
|
|
734
|
-
'excel-formula',
|
|
735
|
-
'factor',
|
|
736
|
-
'false',
|
|
737
|
-
'firestore-security-rules',
|
|
738
|
-
'flow',
|
|
739
|
-
'fortran',
|
|
740
|
-
'fsharp',
|
|
741
|
-
'ftl',
|
|
742
|
-
'gap',
|
|
743
|
-
'gcode',
|
|
744
|
-
'gdscript',
|
|
745
|
-
'gedcom',
|
|
746
|
-
'gherkin',
|
|
747
|
-
'git',
|
|
748
|
-
'glsl',
|
|
749
|
-
'gml',
|
|
750
|
-
'gn',
|
|
751
|
-
'go-module',
|
|
752
|
-
'go',
|
|
753
|
-
'graphql',
|
|
754
|
-
'groovy',
|
|
755
|
-
'haml',
|
|
756
|
-
'handlebars',
|
|
757
|
-
'haskell',
|
|
758
|
-
'haxe',
|
|
759
|
-
'hcl',
|
|
760
|
-
'hlsl',
|
|
761
|
-
'hoon',
|
|
762
|
-
'hpkp',
|
|
763
|
-
'hsts',
|
|
764
|
-
'http',
|
|
765
|
-
'ichigojam',
|
|
766
|
-
'icon',
|
|
767
|
-
'icu-message-format',
|
|
768
|
-
'idris',
|
|
769
|
-
'iecst',
|
|
770
|
-
'ignore',
|
|
771
|
-
'inform7',
|
|
772
|
-
'ini',
|
|
773
|
-
'io',
|
|
774
|
-
'j',
|
|
775
|
-
'java',
|
|
776
|
-
'javadoc',
|
|
777
|
-
'javadoclike',
|
|
778
|
-
'javascript',
|
|
779
|
-
'javastacktrace',
|
|
780
|
-
'jexl',
|
|
781
|
-
'jolie',
|
|
782
|
-
'jq',
|
|
783
|
-
'js-extras',
|
|
784
|
-
'js-templates',
|
|
785
|
-
'jsdoc',
|
|
786
|
-
'json',
|
|
787
|
-
'json5',
|
|
788
|
-
'jsonp',
|
|
789
|
-
'jsstacktrace',
|
|
790
|
-
'jsx',
|
|
791
|
-
'julia',
|
|
792
|
-
'keepalived',
|
|
793
|
-
'keyman',
|
|
794
|
-
'kotlin',
|
|
795
|
-
'kumir',
|
|
796
|
-
'kusto',
|
|
797
|
-
'latex',
|
|
798
|
-
'latte',
|
|
799
|
-
'less',
|
|
800
|
-
'lilypond',
|
|
801
|
-
'liquid',
|
|
802
|
-
'lisp',
|
|
803
|
-
'livescript',
|
|
804
|
-
'llvm',
|
|
805
|
-
'log',
|
|
806
|
-
'lolcode',
|
|
807
|
-
'lua',
|
|
808
|
-
'magma',
|
|
809
|
-
'makefile',
|
|
810
|
-
'markdown',
|
|
811
|
-
'markup-templating',
|
|
812
|
-
'markup',
|
|
813
|
-
'matlab',
|
|
814
|
-
'maxscript',
|
|
815
|
-
'mel',
|
|
816
|
-
'mermaid',
|
|
817
|
-
'mizar',
|
|
818
|
-
'mongodb',
|
|
819
|
-
'monkey',
|
|
820
|
-
'moonscript',
|
|
821
|
-
'n1ql',
|
|
822
|
-
'n4js',
|
|
823
|
-
'nand2tetris-hdl',
|
|
824
|
-
'naniscript',
|
|
825
|
-
'nasm',
|
|
826
|
-
'neon',
|
|
827
|
-
'nevod',
|
|
828
|
-
'nginx',
|
|
829
|
-
'nim',
|
|
830
|
-
'nix',
|
|
831
|
-
'nsis',
|
|
832
|
-
'objectivec',
|
|
833
|
-
'ocaml',
|
|
834
|
-
'opencl',
|
|
835
|
-
'openqasm',
|
|
836
|
-
'oz',
|
|
837
|
-
'parigp',
|
|
838
|
-
'parser',
|
|
839
|
-
'pascal',
|
|
840
|
-
'pascaligo',
|
|
841
|
-
'pcaxis',
|
|
842
|
-
'peoplecode',
|
|
843
|
-
'perl',
|
|
844
|
-
'php-extras',
|
|
845
|
-
'php',
|
|
846
|
-
'phpdoc',
|
|
847
|
-
'plsql',
|
|
848
|
-
'powerquery',
|
|
849
|
-
'powershell',
|
|
850
|
-
'processing',
|
|
851
|
-
'prolog',
|
|
852
|
-
'promql',
|
|
853
|
-
'properties',
|
|
854
|
-
'protobuf',
|
|
855
|
-
'psl',
|
|
856
|
-
'pug',
|
|
857
|
-
'puppet',
|
|
858
|
-
'pure',
|
|
859
|
-
'purebasic',
|
|
860
|
-
'purescript',
|
|
861
|
-
'python',
|
|
862
|
-
'q',
|
|
863
|
-
'qml',
|
|
864
|
-
'qore',
|
|
865
|
-
'qsharp',
|
|
866
|
-
'r',
|
|
867
|
-
'racket',
|
|
868
|
-
'reason',
|
|
869
|
-
'regex',
|
|
870
|
-
'rego',
|
|
871
|
-
'renpy',
|
|
872
|
-
'rest',
|
|
873
|
-
'rip',
|
|
874
|
-
'roboconf',
|
|
875
|
-
'robotframework',
|
|
876
|
-
'ruby',
|
|
877
|
-
'rust',
|
|
878
|
-
'sas',
|
|
879
|
-
'sass',
|
|
880
|
-
'scala',
|
|
881
|
-
'scheme',
|
|
882
|
-
'scss',
|
|
883
|
-
'shell-session',
|
|
884
|
-
'smali',
|
|
885
|
-
'smalltalk',
|
|
886
|
-
'smarty',
|
|
887
|
-
'sml',
|
|
888
|
-
'solidity',
|
|
889
|
-
'solution-file',
|
|
890
|
-
'soy',
|
|
891
|
-
'sparql',
|
|
892
|
-
'splunk-spl',
|
|
893
|
-
'sqf',
|
|
894
|
-
'sql',
|
|
895
|
-
'squirrel',
|
|
896
|
-
'stan',
|
|
897
|
-
'stylus',
|
|
898
|
-
'swift',
|
|
899
|
-
'systemd',
|
|
900
|
-
't4-cs',
|
|
901
|
-
't4-templating',
|
|
902
|
-
't4-vb',
|
|
903
|
-
'tap',
|
|
904
|
-
'tcl',
|
|
905
|
-
'textile',
|
|
906
|
-
'toml',
|
|
907
|
-
'tremor',
|
|
908
|
-
'tsx',
|
|
909
|
-
'tt2',
|
|
910
|
-
'turtle',
|
|
911
|
-
'twig',
|
|
912
|
-
'typescript',
|
|
913
|
-
'typoscript',
|
|
914
|
-
'unrealscript',
|
|
915
|
-
'uorazor',
|
|
916
|
-
'uri',
|
|
917
|
-
'v',
|
|
918
|
-
'vala',
|
|
919
|
-
'vbnet',
|
|
920
|
-
'velocity',
|
|
921
|
-
'verilog',
|
|
922
|
-
'vhdl',
|
|
923
|
-
'vim',
|
|
924
|
-
'visual-basic',
|
|
925
|
-
'warpscript',
|
|
926
|
-
'wasm',
|
|
927
|
-
'web-idl',
|
|
928
|
-
'wiki',
|
|
929
|
-
'wolfram',
|
|
930
|
-
'wren',
|
|
931
|
-
'xeora',
|
|
932
|
-
'xml-doc',
|
|
933
|
-
'xojo',
|
|
934
|
-
'xquery',
|
|
935
|
-
'yaml',
|
|
936
|
-
'yang',
|
|
937
|
-
'zig',
|
|
938
|
-
] as const
|
|
939
|
-
const supportedLanguagesSet = new Set(supportedLanguages)
|
|
940
|
-
|
|
941
649
|
type ComponentsMap = { [k in (typeof nativeTags)[number]]?: any } & {
|
|
942
650
|
[key: string]: any
|
|
943
651
|
}
|