@@ -199,5 +199,165 @@ ruleTest({
199199 ] ,
200200 } ,
201201 } ,
202+ { // accounts for https://github.com/platers/obsidian-linter/issues/1082
203+ testName : 'Make sure that literal operator `|` is handled correctly' ,
204+ before : dedent `
205+ ---
206+ sorting-spec: |
207+ order-desc: a-z
208+ first: alphabetical
209+ ---
210+ ` ,
211+ after : dedent `
212+ ---
213+ first: alphabetical
214+ sorting-spec: |
215+ order-desc: a-z
216+ ---
217+ ` ,
218+ options : {
219+ yamlKeyPrioritySortOrder : [
220+ 'first' ,
221+ 'sorting-spec:' ,
222+ ] ,
223+ } ,
224+ } ,
225+ { // accounts for https://github.com/platers/obsidian-linter/issues/912
226+ testName : 'Make sure that lots of nesting does not get broken' ,
227+ before : dedent `
228+ ---
229+ AAA:
230+ - BBB: x
231+ CCC: x
232+ - DDD: x
233+ EEE: x
234+ FFF:
235+ - GGG: x
236+ - HHH
237+ III: x
238+ FFF:
239+ -${ ' ' }
240+ ---
241+ ` ,
242+ after : dedent `
243+ ---
244+ AAA:
245+ - BBB: x
246+ CCC: x
247+ - DDD: x
248+ EEE: x
249+ FFF:
250+ - GGG: x
251+ - HHH
252+ III: x
253+ FFF:
254+ -${ ' ' }
255+ ---
256+ ` , // note that this does look wonky, but it works the same in Obsidian, so I am going to consider this fine for now
257+ // see https://github.com/eemeli/yaml/issues/590 for more information on this
258+ options : {
259+ yamlSortOrderForOtherKeys : 'Ascending Alphabetical' ,
260+ } ,
261+ } ,
262+ { // accounts for https://github.com/platers/obsidian-linter/issues/660
263+ testName : 'Make sure that comments are not removed when sorting' ,
264+ before : dedent `
265+ ---
266+ created: 2023-02-18T10:53:01+00:00
267+ # Dont remove me
268+ disabled rules: [capitalize-headings]
269+ modified: 2023-03-20T14:53:42+00:00
270+ ---
271+ ` ,
272+ after : dedent `
273+ ---
274+ created: 2023-02-18T10:53:01+00:00
275+ # Dont remove me
276+ disabled rules: [capitalize-headings]
277+ modified: 2023-03-20T14:53:42+00:00
278+ ---
279+ ` ,
280+ options : {
281+ yamlSortOrderForOtherKeys : 'Ascending Alphabetical' ,
282+ } ,
283+ } ,
284+ { // accounts for https://github.com/platers/obsidian-linter/issues/660
285+ testName : 'Make sure that scalars are not removed when sorting' ,
286+ before : dedent `
287+ ---
288+ name: John
289+ husband: Tim
290+ biography: |
291+ A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap.
292+ ---
293+ ` ,
294+ after : dedent `
295+ ---
296+ biography: |
297+ A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap. A very nice chap.
298+ husband: Tim
299+ name: John
300+ ---
301+ ` ,
302+ options : {
303+ yamlSortOrderForOtherKeys : 'Ascending Alphabetical' ,
304+ } ,
305+ } ,
306+ { // accounts for https://github.com/platers/obsidian-linter/issues/1258
307+ testName : 'Make sure that folded block scalars are not broken up when sorting' ,
308+ before : dedent `
309+ ---
310+ aliases: []
311+ tags:
312+ - media/podcast/episode
313+ description: >-
314+ Follow our ad-free Rain Playlist here:
315+ image: 'https://i.scdn.co/image/ab6765630000ba8a8d796ac81fdad1d895dd28a1'
316+ links:
317+ - https://open.spotify.com/episode/1LSnoZVPWB8ynOCMCwKw5S
318+ showName: ASMR Rain Recordings
319+ created: 11-05-2024 21:09
320+ updated: 13-01-2025 08:16
321+ ---
322+ ` ,
323+ after : dedent `
324+ ---
325+ aliases: []
326+ created: 11-05-2024 21:09
327+ description: >-
328+ Follow our ad-free Rain Playlist here:
329+ image: 'https://i.scdn.co/image/ab6765630000ba8a8d796ac81fdad1d895dd28a1'
330+ links:
331+ - https://open.spotify.com/episode/1LSnoZVPWB8ynOCMCwKw5S
332+ showName: ASMR Rain Recordings
333+ tags:
334+ - media/podcast/episode
335+ updated: 13-01-2025 08:16
336+ ---
337+ ` ,
338+ options : {
339+ yamlSortOrderForOtherKeys : 'Ascending Alphabetical' ,
340+ } ,
341+ } ,
342+ { // accounts for https://github.com/platers/obsidian-linter/issues/660
343+ testName : 'Make sure that comments on an array do not cause issues when sorting' ,
344+ before : dedent `
345+ ---
346+ Ingredients: # [\`<free text for ingredient>\`,\`<amount>\`, \`<unit>\`, \`<form>\`, \`<note>\`]
347+ - [Watermelon, 80 g, cubed, note]
348+ - [sugar, 20 g]
349+ ---
350+ ` ,
351+ after : dedent `
352+ ---
353+ Ingredients: # [\`<free text for ingredient>\`,\`<amount>\`, \`<unit>\`, \`<form>\`, \`<note>\`]
354+ - [Watermelon, 80 g, cubed, note]
355+ - [sugar, 20 g]
356+ ---
357+ ` ,
358+ options : {
359+ yamlSortOrderForOtherKeys : 'Ascending Alphabetical' ,
360+ } ,
361+ } ,
202362 ] ,
203363} ) ;
0 commit comments