nothingislost / obsidian-dynamic-highlights

An experimental Obsidian plugin that highlights all occurrences of the word under the cursor
MIT License
132 stars 7 forks source link

Immediately crashes on mobile for this regex #80

Open Caffa opened 2 months ago

Caffa commented 2 months ago

Steps to reproduce:

  1. Import in these persistent highlights

    {
    "sidenote": {
    "class": "sidenote",
    "color": "#42188038",
    "regex": true,
    "query": "<s>(.*)</s>",
    "mark": [
      "match"
    ],
    "css": "/* Sidenotes with HTML-Tags\n ------------------------*/\n\n/* This class is assigned to <s> HTML Tags via the Dynamic Highlights Plugin.*/\n.sidenote {\n color:  var(--interactive-accent);\n}\n\n\n/* Side Symbol */\n:not(.hide-sides) > s:before {\n    content:  '● ';\n    color: var(--interactive-accent) ;\n    font-size: 1em;\n    margin-left: -10px;\n}\n\n/* Content of the Sidenote */\n:not(.hide-sides) > s {\n  float: right;\n  position: relative;\n  width: 150px;\n  clear: left;\n  margin-right: -176px;\n  background-color: transparent;\n  text-decoration: unset;\n  text-align: left;\n  line-height: 1.5em;\n  font-size: 0.7em;\n  color: var(--text);\n}\n\n\n/* Content of the Sidenote when not hovered */\n.hide-sides s {\n  color: transparent;\n}\n\n/* All children of the sidenote (bold, links etc.) should not show when not hovered */\n.hide-sides s > * {\n  visibility: hidden;\n}\n\n/* Show on hover */\n.hide-sides s:hover {\n  color: unset;\n}\n\n.hide-sides s:hover > * {\n  visibility: visible;\n}\n"
    },
    "Filler-Words": {
    "class": "Filler-Words",
    "color": "#2D801838",
    "regex": false,
    "query": "\\b([Aa] bit|[Aa]bsolutely|[Aa]ctually|[Aa]nd all that|[Aa]nd so forth|[Aa]nyway|[Bb]asically|[Cc]ertainly|[Cc]learly|[Cc]ompletely|[Dd]efinitely|[Ee]ffectively|[Ee]ntirely|[Ee]ssentially|[Ee]vidently|[Ee]xtremely|[Ff]airly|[Ff]rankly|[Ff]requently|[Gg]enerally|[Hh]opefully|[Kk]ind of|[Ll]argely|[Ll]iterally|[Mm]ore or less|[Mm]ostly|[Oo]ccasionally|[Oo]ften|[Oo]verall|[Pp]articularly|[Pp]erhaps|[Pp]ossibly|[Pp]ractically|[Pp]recisely|[Pp]resumably|[Pp]retty|[Pp]rimarily|[Pp]robably|[Pp]urely|[Qq]uite|[Rr]arely|[Rr]ather|[Rr]eally|[Rr]elatively|[Ss]eriously|[Ss]ignificantly|[Ss]imply|[Ss]lightly|[Ss]omehow|[Ss]ort of|[Ss]pecifically|[Ss]trongly|[Ss]upposedly|[Ss]urely|[Tt]he fact that|[Tt]otally|[Tt]ruly|[Tt]ypically|[Uu]ltimately|[Uu]sually|[Vv]ery|[Vv]irtually|[Ww]idely)\\b",
    "mark": [
      "match"
    ],
    "css": ".cm-line .Filler-Words{\n\ttext-decoration: line-through;\n\tbackground: none;\n\tcolor: var(--text-muted);\n}\n\n/* where to disable */\n.HyperMD-quote.cm-line .Filler-Words,\n.pdf-annotations .cm-line .Filler-Words {\n\ttext-decoration: none;\n\tcolor: unset;\n}"
    },
    "Thought": {
    "class": "Thought",
    "color": "#7C7C793D",
    "regex": true,
    "query": "[\\s\"]['‘’](.*?)['‘’][\\s,.\\?!\":]",
    "mark": [
      "match"
    ],
    "css": ".cm-line .Thought{\n\tfont-style: italic;\n\tbackground: none;\n\tcolor: var(--text-italic);\n}\nspan.cm-quote.cm-quote-1 .Thought{\n\tfont-style: italic;\n\tbackground: none;\n\tcolor: var(--text-italic);\n}\n\n/* where to disable */\n.HyperMD-quote.cm-line .Thought,\n.pdf-annotations .cm-line .Thought {\n\ttext-decoration: none;\n\tcolor: unset;\n}"
    },
    "Dialogue": {
    "class": "Dialogue",
    "color": "#9763E230",
    "regex": true,
    "query": "[“\"”](.*?)[“\"”]",
    "mark": [
      "match",
      "group"
    ],
    "css": ""
    }
    }
  2. Have the below css snippet saved in a css file in .obsidian/snippets folder and enabled in appearances

    
    .theme-light{
    --text-italic: #fc6413;
    --text-bold: #8269FF;

}

.theme-dark{ --text-italic: #f2bb50; --text-bold: #8269FF;

}

.cm-strong{ color: var(--text-bold); }

.cm-em{ color: var(--text-italic); }

span.cm-quote.cm-quote-1.cm-strong { color: var(--text-bold); }

span.cm-quote.cm-quote-1.cm-em { color: var(--text-italic); }


3. Try to type ' in a situation where the double matching '' will appear, which should trigger the Thought highlighter.

This has only recently happened, 
- It only affects mobile and not mac 
- If I disable the Thought highlight this crashing goes away
- My vault size is very big (2.51 GB, mostly text files) - each file is usually around 10000 to 20000 words

![image](https://github.com/nothingislost/obsidian-dynamic-highlights/assets/1797721/b4871a1e-da5c-4872-b217-52363cbae07f)
So the Thoughts highlight does between '' and the Dialogue highlight does between "" characters. But the Thoughts highlight has to exclude words with ' such as Harry's 

Debug log

SYSTEM INFO: Obsidian version: v1.6.3 Installer version: v1.5.3 Operating system: Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 23.5.0 Login status: logged in Catalyst license: none Insider build toggle: off Live preview: on Base theme: dark Community theme: Everforest v0.0.0 Snippets enabled: 7 Restricted mode: off Plugins installed: 161 Plugins enabled: 39 1: Quick Plugin Switcher v7.10.1 2: Advanced URI v1.40.1 3: Templater v2.3.3 4: Copy Block Link v1.0.4 5: File Tree Alternative v2.5.9 6: Hider v1.3.1 7: Hot Reload v0.1.11 8: Hotkey Helper v0.3.18 9: Smart Random Note v0.2.1 10: Style Settings v1.0.8 11: Theme Picker v1.0.8 12: Zoom v1.1.2 13: Settings Search v1.3.10 14: Another Quick Switcher v11.4.1 15: Excalidraw v2.2.4 16: Scroll to Top v2.1.4 17: Solve v1.0.2 18: Supercharged Links v0.12.1 19: Workspaces Plus v0.3.3 20: MySnippets v1.2.3 21: Theme Toggler v1.0.1 22: Typewriter Scroll v0.2.2 23: Better Search Views v0.2.2 24: Settings profiles v0.5.7 25: QuickAdd v1.8.1 26: Iconize v2.12.1 27: BRAT v1.0.1 28: Plugin Manager v0.1.6 29: Omnisearch v1.23.0 30: Auto Link Title v1.5.4 31: Editor Width Slider v1.0.5 32: Dynamic Highlights v0.3.1 33: Recent Files v1.4.1 34: Various Complements v10.0.0 35: Quiet Outline v0.3.31 36: Dataview v0.5.66 37: Shell commands v0.22.0 38: Current Folder Notes v1.6.0 39: ExcaliBrain v0.2.15

RECOMMENDATIONS: Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets. Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.