src/lib/markbind/src/parser.js
function extractImportedVariables(context) {
  if (!context.importedVariables) {
    return {};
  }
  const importedVariables = {};
  Object.entries(context.importedVariables).forEach(([src, variables]) => {
    variables.forEach((variableName) => {
      const actualFilePath = utils.isUrl()
        ? src
        : path.resolve(path.dirname(context.cwf), decodeURIComponent(url.parse(src).path));
      if (!VARIABLE_LOOKUP[actualFilePath] || !VARIABLE_LOOKUP[actualFilePath][variableName]) {
        // eslint-disable-next-line no-console
        console.warn(`Missing variable ${variableName} in ${src} referenced by ${context.cwf}\n`);
        return;
      }
      const variableValue = VARIABLE_LOOKUP[actualFilePath][variableName];
      if (!importedVariables[variableName]) {
        importedVariables[variableName] = variableValue;
      }
    });
  });
  return importedVariables;
}
function extractImportedVariables(context) {
  if (!context.importedVariables) {
    return {};
  }
  const importedVariables = {};
  Object.entries(context.importedVariables).forEach(([src, variables]) => {
    variables.forEach((variableName) => {
      const actualFilePath = utils.isUrl()
        ? src
        : path.resolve(path.dirname(context.cwf), decodeURIComponent(url.parse(src).path));
      if (!VARIABLE_LOOKUP[actualFilePath] || !VARIABLE_LOOKUP[actualFilePath][variableName]) {
        // eslint-disable-next-line no-console
        console.warn(`Missing variable ${variableName} in ${src} referenced by ${context.cwf}\n`);
        return;
      }
      const variableValue = VARIABLE_LOOKUP[actualFilePath][variableName];
      if (!importedVariables[variableName]) {
        importedVariables[variableName] = variableValue;
      }
    });
  });
  return importedVariables;
}
function extractImportedVariables ( context ) { if ( ! context . importedVariables ) { return { } ; } const importedVariables = { } ; Object . entries ( context . importedVariables ) . forEach ( ( [ src , variables ] ) => { variables . forEach ( ( variableName ) => { const actualFilePath = utils . isUrl ( ) ? src : path . resolve ( path . dirname ( context . cwf ) , decodeURIComponent ( url . parse ( src ) . path ) ) ; if ( ! VARIABLE_LOOKUP [ actualFilePath ] || ! VARIABLE_LOOKUP [ actualFilePath ] [ variableName ] ) { // eslint-disable-next-line no-console console . warn ( ` ${ variableName } ${ src } ${ context . cwf } \n ` ) ; return ; } const variableValue = VARIABLE_LOOKUP [ actualFilePath ] [ variableName ] ; if ( ! importedVariables [ variableName ] ) { importedVariables [ variableName ] = variableValue ; } } ) ; } ) ; return importedVariables ; }
Extract imported page variables from a page
@param context of the page
Extract imported page variables from a page