View Single Post
Old 11-22-2021, 04:13 AM   #2
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,116
Karma: 1954138
Join Date: Aug 2015
Device: Kindle
Tag Actions

This is the main action of the plugin. It allows the user to apply a variety of actions on tags, which are located based on range of tag criteria configured by the user.
  • TAG_SELECTION
    There are two mode to tag TAG_SELECTION
    1. Individual Tag(s)
      The default option where you select single tag(s) based on criteria, and apply action on them individually
    2. Range(s) of Tags
      Here you can choose range(s) of tags, where you will be able to apply actions on them collectively. e.g wrap them in another tag. To be able to select a range, you need to set criteria of two tags:
      1. First tag in the range
      2. Last tag in the range
      Also there two optional settings to abort the range, even if you are able to match the first and last tags:
      1. (Optional) Abort: Here you specify criteria for tag that if found between the first and last tags, the range broken and not selected</dd>
      2. (Optional) Max Steps: The maximum number of tags between the first and last tag. If actual number in a range is higher than the value specified here, the range will not be selected.

  • Info on Tag Criteria
    Opens a dialog for you to select criteria by which to select tags. It allows for boolean or/and criteria, or even nested groups of or/any (by choosing "match all"/"match any") from the dropdown menu.
    Here is a list of the filters by which you can match a tag:
    1. Tag Name: Allows for regular expression or exact matching of tag name.
    2. Attribute: Allows for regular expression or exact matching of different attributes. For multivalue attributes like classes, you can also match a single class by choosing the contain option from the dropdown.
    3. Text: This can apply to the text of tag itself. Or the text immediately before or after i.e. The tail of the previous or next sibling if any
    4. Related Tag: Allows you choose a tag by criteria of its relative tag. e.g. a tag that has a child tag with certain class name.
    5. Style Property: Allows you choose a tag based on its style e.g. font-size, color .... etc
    6. Code: If you know how to code in python, you can refine your criteria by using this filter.


  • ACTIONS:
    Perform one of the following actions on the selected tags/ranges:
    1. Modify Tag: Allows you modify a tag in a variety of way:
      • Modify tag name
      • Delete classes or other attributes
      • Add or append new classes
      • Add new attributes
    2. Delete: Delete tag(s) and its contents
    3. Wrap: Wrap the tag(s) in a new tag
    4. Unwrap: Delete only the tag but keeping its text
    5. Insert Before: Insert a text or tag before
    6. Insert After: Insert a text or tag after
    7. Search and Replace: Perform a search and replace on the on the whole element (tag and text). This supports regex and calibre's replace function
    8. Code: If you can program in python, you can use this to apply your custom action

Sample chains
  • Merge adjacent span tags that have the class "italic" into single span tag. Can be adapted for different tag e.g. <i> tags. You can download the chain from here.
  • Merge adjacent span tags that have the exact same classes. You can download the chain from here.
  • Convert paragraphs into headings based on font-size. You can
    download the chain from here.
  • Modified version of the above chain, which adds other criteria to convert into h1, h2 heading. The paragraph must have less than 80 letters, must be centered and the text must be bold. You can download the chain from here.
Attached Thumbnails
Click image for larger version

Name:	3.png
Views:	348
Size:	65.6 KB
ID:	198348   Click image for larger version

Name:	4.png
Views:	304
Size:	72.4 KB
ID:	198349   Click image for larger version

Name:	11.png
Views:	306
Size:	54.2 KB
ID:	198350  

Last edited by capink; 12-12-2022 at 12:38 AM.
capink is offline   Reply With Quote