{"id":678,"date":"2025-11-03T20:57:51","date_gmt":"2025-11-04T01:57:51","guid":{"rendered":"https:\/\/havalite.com\/?p=678"},"modified":"2025-11-03T21:01:10","modified_gmt":"2025-11-04T02:01:10","slug":"introducing-ala_marker-a-multi-color-text-highlighter-plugin-for-jquery","status":"publish","type":"post","link":"https:\/\/havalite.com\/?p=678","title":{"rendered":"Introducing ala_marker: A Multi-Color Text Highlighter Plugin for jQuery"},"content":{"rendered":"<p class=\"lead\">ala_marker brings multi-color, regex-powered highlights to textareas using a transparent overlay \u2014 caret-safe, LTR\/RTL-aware, and cross-browser friendly.<\/p>\n<article>\n<section>\n<h2>Core Concept<\/h2>\n<p>Instead of altering the textarea content, <strong>ala_marker<\/strong> builds a transparent overlay <code>&lt;div&gt;<\/code> on top of it. The overlay renders the highlights while the underlying text stays fully editable. Colors are applied with slight opacity so the caret never gets \u201clost\u201d behind solid fills.<\/p>\n<\/section>\n<section>\n<h2>Key Features<\/h2>\n<ul>\n<li><strong>Multiple colors:<\/strong> Assign as many colors as you like; each color can cover several words, characters, or patterns.<\/li>\n<li><strong>Regex support:<\/strong> Provide full regular expressions for precise matching \u2014 ideal for multilingual text and symbols.<\/li>\n<li><strong>LTR\/RTL detection:<\/strong> The plugin automatically handles both directions, with a test button to preview behavior.<\/li>\n<li><strong>Cross-browser tuning:<\/strong> Small visual offsets accommodate subtle differences (notably in Firefox) for consistent alignment.<\/li>\n<li><strong>Non-intrusive:<\/strong> The textarea value remains unchanged, so copy\/paste and processing are unaffected.<\/li>\n<\/ul>\n<\/section>\n<section>\n<h2>How It Works<\/h2>\n<p>Apply the plugin to a textarea by its ID. In options, pass a map of <code>{ regexPattern: color }<\/code>. The plugin rebuilds a mirrored HTML view with colored spans on its overlay while keeping the original textarea interactive underneath.<\/p>\n<\/section>\n<section class=\"card\">\n<h3 style=\"margin-top: 0;\">Quick Start<\/h3>\n<p class=\"small\">Include jQuery and the plugin file, then initialize:<\/p>\n<pre><code>&lt;!-- jQuery and ala_marker assets --&gt;\r\n&lt;script src=\"https:\/\/code.jquery.com\/jquery-3.7.1.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"\/path\/to\/ala_marker.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;textarea id=\"myTextarea\"&gt;Type here\u2026&lt;\/textarea&gt;\r\n\r\n&lt;script&gt;\r\n\/\/ Initialize ala_marker (example palette)\r\n$('#myTextarea').ala_marker({\r\n  ala_keywords: {\r\n    '\\\\b(love|peace|hope)\\\\b': '#ff9', \/\/ soft yellow\r\n    '[0-9]+': '#9ff',                  \/\/ light blue\r\n    '[?!]': '#f99'                     \/\/ gentle red\r\n  }\r\n});\r\n&lt;\/script&gt;\r\n<\/code><\/pre>\n<p class=\"small\">Tip: Colors are rendered with opacity by design to keep the caret visible.<\/p>\n<\/section>\n<section>\n<h2>Developer Notes<\/h2>\n<p>Browsers can render borders and text metrics a few pixels differently. During testing, Firefox tended to shift the overlay slightly; a minor constant offset corrects this so the overlay stays in sync with the underlying textarea.<\/p>\n<\/section>\n<section>\n<h2>Why Transparency Matters<\/h2>\n<p>Solid backgrounds can hide the caret. Using partially transparent highlights ensures the caret remains visible, making editing smooth and predictable.<\/p>\n<p>You are free to use, modify, and distribute this plugin.<\/p>\n<\/section>\n<section>\n<h2>Demo &amp; Download<\/h2>\n<div class=\"linkstrip\"><a href=\"https:\/\/havalite.com\/tools\/ala_marker\/\" rel=\"noopener\">Live Demo &amp; Download<\/a><\/div>\n<\/section>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>ala_marker brings multi-color, regex-powered highlights to textareas using a transparent overlay \u2014 caret-safe, LTR\/RTL-aware, and cross-browser friendly. Core Concept Instead of altering the textarea content, ala_marker builds a transparent overlay &lt;div&gt; on top of it. The overlay renders the highlights while the underlying text stays fully editable. Colors are applied with slight opacity so the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68,6,67],"tags":[],"class_list":["post-678","post","type-post","status-publish","format-standard","hentry","category-download","category-jquery-plugins","category-projects"],"_links":{"self":[{"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":7,"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":685,"href":"https:\/\/havalite.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions\/685"}],"wp:attachment":[{"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/havalite.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}