Skip to content

Suggestion: Small improvement to MathCAT's range handling in unicode files #590

@NSoiffer

Description

@NSoiffer

When reading rule files, MathCAT supports ranges. For example

 - "𝗮-𝘇":    # 0x1d5ee - 0x1d607
    - test:
        if: "not($IgnoreBold)"
        then: [t: "bold"]
    - spell: "translate('.', '𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇', 'abcdefghijklmnopqrstuvwxyz')"

This gets rewritten to 26 rules for each letter, with "." replaced by the letter. When there is a translate, an optimization is to avoid the translate so that you end up with something like

 - "𝗮":    # 0x1d5ee - 0x1d607
    - test:
        if: "not($IgnoreBold)"
        then: [t: "bold"]
    - spell: "a"

However, in some cases such as in braille, we need to invoke the rule for "a". There is a hack in tts.rs that deals with the recursion and uses spell. Any change would need to make sure that still triggers after this change.

This is a minor optimization that probably doesn't result in a noticeable speedup. Still, it is kind of silly to call translate on a constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions