import path from "path" ; import Immutable from "immutable" ; import markdownParser from "@honkit/markdown-legacy" ; import asciidocParser from "@honkit/asciidoc" ; import EXTENSIONS_MARKDOWN from "./constants/extsMarkdown" ; import EXTENSIONS_ASCIIDOC from "./constants/extsAsciidoc" ; import Parser from "./models/parser" ; const parsers = Immutable . List ( [ Parser . create ( "markdown" , EXTENSIONS_MARKDOWN , markdownParser ) , Parser . create ( "asciidoc" , EXTENSIONS_ASCIIDOC , asciidocParser ) , ] ) ; param { string } name return { Parser | undefined } function getParser ( name ) { return parsers . find ( ( parser ) => { return parser . getName ( ) === name ; } ) ; } param { string } ext return { Parser | undefined } function getParserByExt ( ext ) { return parsers . find ( ( parser ) => { return parser . matchExtension ( ext ) ; } ) ; } param { string } ext return { Parser | undefined } function getParserForFile ( filename ) { return getParserByExt ( path . extname ( filename ) ) ; } const extensions = parsers . map ( ( parser ) => { return parser . getExtensions ( ) ; } ) . flatten ( ) ; export default { extensions : extensions , get : getParser , getByExt : getParserByExt , getForFile : getParserForFile , } ;