View Single Post
Old 11-28-2018, 11:54 AM   #271
geek1011
Wizard
geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.
 
Posts: 2,818
Karma: 7424433
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD, Clara BW, Libra Colour
Quote:
Originally Posted by jackie_w View Post
@geek1011,

Re: ReplaceZlibGroup

Please can you also show an example of how to use this for the occasions when I prefer to have the Find: and Replace: statements on separate lines to facilitate comparing the find/replace strings.

ETA: Ideally, I'd like to be able to mix and match Find/Replace one-liners and multi-liners in the same ReplaceZlibGroup

Here's an extract from a very large patch that I have. How would I use ReplaceZlibGroup to group these 4 find/replace together without losing the last 2 as multi-liners?

Spoiler:
Code:
jackie_w General GUI:
  - Enabled: no
  - Description: General GUI
  - FindZlib: "HeaderSmallElidedLabel"
  #
  # popup footnote header (HeaderMediumElidedLabel,HeaderMediumTouchLabel,HeaderMediumLabel ???)
  # free some space
  - ReplaceZlib: {Offset: 0, Find: "HeaderMediumElidedLabel[qApp_localeName=\"ja_JP\"],\nHeaderMediumTouchLabel[qApp_localeName=\"ja_JP\"],\nHeaderMediumLabel[qApp_localeName=\"ja_JP\"] {\n  font-family: Sans-SerifJP, sans-serif;\n  font-style: normal;\n}\nHeaderSmallLabel", Replace: "HeaderSmallLabel"}
  - ReplaceZlib: {Offset: 0, Find: "HeaderSmallLabel[qApp_localeName=\"ja_JP\"] {\n  font-family: Sans-SerifJP, sans-serif;\n  font-style: normal;\n}\nHeaderSmallElidedLabel", Replace: "HeaderSmallElidedLabel"}
  #
  # Book Title in Book list (HeaderSmallElidedLabel): reduce font-size and to sans-serif, bold
  - ReplaceZlib:
      Offset: 0
      Find:    "HeaderSmallElidedLabel,\nHeaderSmallItalicLabel {\n  font-family: Georgia;\n  font-style: italic;\n  font-size: 23px;\n  padding-left: 12px;\n  padding-right: 12px;\n  qproperty-alignment: 'AlignLeft|AlignVCenter';\n}"
      Replace: "HeaderSmallElidedLabel,\nHeaderSmallItalicLabel {\n  font-family: Trebuchet, Avenir;\n  font-weight: bold;\n  font-size: 23px;\n  padding-left: 12px;\n  padding-right: 12px;\n  qproperty-alignment: 'AlignLeft|AlignVCenter';\n}"
  - ReplaceZlib:
      Offset: 0
      Find:    "HeaderSmallElidedLabel[qApp_deviceIsDragon=true],\nHeaderSmallItalicLabel[qApp_deviceIsDragon=true] {\n  font-size: 36px;\n  padding-left: 20px;\n  padding-right: 20px;\n}\nHeaderSmallElidedLabel[qApp_deviceIsAlyssum=true],\nHeaderSmallItalicLabel[qApp_deviceIsAlyssum=true] {\n  font-size: 39px;\n}\nHeaderSmallElidedLabel[qApp_deviceIsNova=true],\nHeaderSmallItalicLabel[qApp_deviceIsNova=true] {\n  font-size: 39px;\n}\nHeaderSmallElidedLabel[qApp_deviceIsDaylight=true],\nHeaderSmallItalicLabel[qApp_deviceIsDaylight=true] {\n  font-size: 47px;\n  padding-left: 26px;\n  padding-right: 26px;\n}\nHeaderSmallElidedLabel[qApp_localeName=\"ja_JP\"],\nHeaderSmallItalicLabel[qApp_localeName=\"ja_JP\"] {\n  font-family: Sans-SerifJP, sans-serif;\n  font-style: normal;\n  qproperty-forceLeading: 5;\n}"
      Replace: "HeaderSmallElidedLabel[qApp_deviceIsDragon=true],\nHeaderSmallItalicLabel[qApp_deviceIsDragon=true] {\n  font-size: 32px;\n  padding-left: 20px;\n  padding-right: 20px;\n}\nHeaderSmallElidedLabel[qApp_deviceIsAlyssum=true],\nHeaderSmallItalicLabel[qApp_deviceIsAlyssum=true] {\n  font-size: 36px;\n}\nHeaderSmallElidedLabel[qApp_deviceIsNova=true],\nHeaderSmallItalicLabel[qApp_deviceIsNova=true] {\n  font-size: 36px;\n}\nHeaderSmallElidedLabel[qApp_deviceIsDaylight=true],\nHeaderSmallItalicLabel[qApp_deviceIsDaylight=true] {\n  font-size: 40px;\n  padding-left: 26px;\n  padding-right: 26px;\n}"
  #
It's all YAML, and you can find all the possible forms here: http://yaml.org/spec/1.2/spec.html . As for your specific question, you can do:

Code:
Example for ReplaceZlibGroup:
  - Enabled: yes
  - Description: An example patch for the new ReplaceZlibGroup instruction.
  - FindZlib: "#someRandomID"
  - ReplaceZlibGroup:
      Offset: 0
      Replacements:
        - Find: "#someRandomID"
          Replace: "#someRandomIDThatMakesTheZlibStreamTooLongWhichWouldHaveErroredWithReplaceZlib"
        - {Find: "#someRandomIDThatMakesTheZlibStreamTooLongWhichWouldHaveErroredWithReplaceZlib", Replace: "#someRandomIDThatIsNowShortEnough"}
geek1011 is offline   Reply With Quote