import * as toml from '@iarna/toml' ; import { SETTING_FRONTMATTER_TYPE } from '../constants' ; import { Settings } from './SettingsHelper' ; export const getFmLanguage = ( ) : string => { const language = Settings . get ( SETTING_FRONTMATTER_TYPE ) as string || "YAML" ; return language . toLowerCase ( ) ; } ; export const getFormatOpts = ( format ) : { language : string ; delimiters : string | [ string , string ] | undefined ; } => { const formats = { yaml : { language : 'yaml' , delimiters : '---' } , toml : { language : 'toml' , delimiters : '+++' } , json : { language : 'json' , delimiters : [ '{' , '}' ] } , } ; return formats [ format ] ; } ; export const TomlEngine = { engines : { toml : { parse : ( value ) => { return toml . parse ( value ) ; } , stringify : ( value ) => { return toml . stringify ( value ) ; } } } } ;