cleanit icon indicating copy to clipboard operation
cleanit copied to clipboard

Using custom config with existing tags

Open ghost opened this issue 2 months ago • 0 comments

Hello,

First off, thanks for making this library, I'm finding a lot of use for it! Really appreciate all the tags that are included out of the box.

I'm looking to add some custom rules, and have made a cleanit-custom.yml config that looks like this (based on the example one given in README):

templates:
  - &custom
    tags:
      - custom
    priority: 10000
    languages: en

rules:
  replace-str-start-J-with-music-note[custom]:
    <<: *custom
    patterns: '^J '
    replacement: '♪ '
  replace-str-end-J-with-music-note[custom]:
    <<: *custom
    patterns: ' J$'
    replacement: ' ♪'
  replace-line-start-J-with-music-note[custom]:
    <<: *custom
    patterns: '\nJ '
    replacement: '\n♪ '
  replace-line-end-J-with-music-note[custom]:
    <<: *custom
    patterns: ' J\n'
    replacement: ' ♪\n'

This runs no problem if I use the -c cleanit-custom.yml -t custom on the command line, and I can verify the output using --debug, but I have a few questions:

  1. How is priority used: is a higher number executed later or sooner than lower numbers?
  2. What are the &custom and *custom supposed to represent?
  3. Probably related to first question, if I wanted to execute all default rules first (-t default), then my custom rules afterwards, how could I do this in a single command? I.e. if I use both the -c and -t switches on the command line, which gets looked at first: the config file then the rules tagged default, or the other way around?

Thanks :)

ghost avatar Oct 05 '25 00:10 ghost