Skip to content

Commit

Permalink
add useLegacyConditions option
Browse files Browse the repository at this point in the history
  • Loading branch information
Feverqwe committed Sep 12, 2024
1 parent 9ad49e8 commit 1c81f72
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ interface YfmConfig {
*/
changelogs?: string | boolean;
analytics?: DocAnalytics;
useLegacyConditions: boolean;
}

export interface YfmArgv extends YfmConfig {
Expand Down
3 changes: 2 additions & 1 deletion src/resolvers/md2html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ function YamlFileTransformer(content: string, transformOptions: FileTransformOpt
}

export function liquidMd2Html(input: string, vars: Record<string, unknown>, path: string) {
const {conditionsInCode} = ArgvService.getConfig();
const {conditionsInCode, useLegacyConditions} = ArgvService.getConfig();

return liquid(input, vars, path, {
conditionsInCode,
withSourceMap: true,
useLegacyConditions,
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/resolvers/md2md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ function copyFile(targetPath: string, targetDestPath: string, options?: PluginOp
}

export function liquidMd2Md(input: string, vars: Record<string, unknown>, path: string) {
const {applyPresets, resolveConditions, conditionsInCode} = ArgvService.getConfig();
const {applyPresets, resolveConditions, conditionsInCode, useLegacyConditions} = ArgvService.getConfig();

Check failure on line 94 in src/resolvers/md2md.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Insert `⏎·······`

return liquid(input, vars, path, {
conditions: resolveConditions,
substitutions: applyPresets,
conditionsInCode,
withSourceMap: true,
keepNotVar: true,
useLegacyConditions,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/metadata/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const parseExistingMetadata = (

export const serializeMetadata = (objectMetadata: FileMetadata) => {
const dumped = unescapeLiquidSubstitutionSyntax(

Check failure on line 106 in src/services/metadata/parse.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `⏎········dump(objectMetadata).trimEnd(),⏎····` with `dump(objectMetadata).trimEnd()`
dump(objectMetadata, {forceQuotes: true}).trimEnd(),
dump(objectMetadata).trimEnd(),
);

// This empty object check is a bit naive
Expand Down
3 changes: 2 additions & 1 deletion src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function liquidFields(
}

export function liquidField(input: string, vars: Record<string, unknown>, path: string) {
const {applyPresets, resolveConditions} = ArgvService.getConfig();
const {applyPresets, resolveConditions, useLegacyConditions} = ArgvService.getConfig();

if (!applyPresets && !resolveConditions) {
return input;
Expand All @@ -173,6 +173,7 @@ export function liquidField(input: string, vars: Record<string, unknown>, path:
conditions: resolveConditions,
keepNotVar: true,
withSourceMap: false,
useLegacyConditions,
});
}

Expand Down

0 comments on commit 1c81f72

Please sign in to comment.