@@ -26,6 +26,11 @@ import {LinterSettings} from '../settings-data';
2626import { RunLinterRulesOptions , TFile } from '../typings/worker' ;
2727import TrailingSpaces from '../rules/trailing-spaces' ;
2828import AutoCorrectCommonMisspellings from '../rules/auto-correct-common-misspellings' ;
29+ import YamlTitle from 'src/rules/yaml-title' ;
30+ import YamlTitleAlias from 'src/rules/yaml-title-alias' ;
31+ import ConsecutiveBlankLines from 'src/rules/consecutive-blank-lines' ;
32+ import { yamlRegex } from 'src/utils/regex' ;
33+ import AddBlankLineAfterYAML from 'src/rules/add-blank-line-after-yaml' ;
2934
3035/**
3136 * Lints the text provided in runOptions.
@@ -92,11 +97,23 @@ function runBeforeRegularRules(runOptions: RunLinterRulesOptions): string {
9297}
9398
9499function runAfterRegularRules ( currentText : string , runOptions : RunLinterRulesOptions ) : string {
95- let newText = currentText ;
100+ let newText = runOptions . oldText ;
96101 const postRuleLogText = getTextInLanguage ( 'logs.post-rules' ) ;
97102 timingBegin ( postRuleLogText ) ;
98103 [ newText ] = CapitalizeHeadings . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules ) ;
99104
105+ [ newText ] = YamlTitle . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules , {
106+ fileName : runOptions . fileInfo . name ,
107+ defaultEscapeCharacter : runOptions . settings . commonStyles . escapeCharacter ,
108+ } ) ;
109+
110+ [ newText ] = YamlTitleAlias . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules , {
111+ fileName : runOptions . fileInfo . name ,
112+ aliasArrayStyle : runOptions . settings . commonStyles . aliasArrayStyle ,
113+ defaultEscapeCharacter : runOptions . settings . commonStyles . escapeCharacter ,
114+ removeUnnecessaryEscapeCharsForMultiLineArrays : runOptions . settings . commonStyles . removeUnnecessaryEscapeCharsForMultiLineArrays ,
115+ } ) ;
116+
100117 [ newText ] = BlockquoteStyle . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules ) ;
101118
102119 [ newText ] = ForceYamlEscape . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules , {
@@ -105,6 +122,13 @@ function runAfterRegularRules(currentText: string, runOptions: RunLinterRulesOpt
105122
106123 [ newText ] = TrailingSpaces . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules ) ;
107124
125+ [ newText ] = ConsecutiveBlankLines . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules ) ;
126+
127+ const yaml = newText . match ( yamlRegex ) ;
128+ if ( yaml != null ) {
129+ [ newText ] = AddBlankLineAfterYAML . applyIfEnabled ( newText , runOptions . settings , runOptions . disabledRules ) ;
130+ }
131+
108132 timingEnd ( postRuleLogText ) ;
109133 timingEnd ( getTextInLanguage ( 'logs.rule-running' ) ) ;
110134 return newText ;
0 commit comments