<h1>Auto-link Hashtags Ultimate</h1>
<p>#Hashtags #are #cool.</p>

<p>This is an improved version of <a href="https://codepen.io/cdevroe">Colin Devroe's</a> simple JavaScript hashtag pen. (Links below are not real.)</p><p>I used Colin's version for a while and it works great for the English language. But, I needed a version which would support more languages and so I present to you, Auto-link Hashtags ULTIMATE!</p><p>It is just as minimal and lightweight as the original, I have simply updated the Regular Expression. The Regular Expression now supports Unicode characters, ignores punctuation, and if something preceeds the hashtag it will gracefully ignore it.</p>
<p>It works just like the big social sites (without the suggestions and trends of course). #cool #neat #lol
<p>Need to ignore markdown? Done. **#ok**. [Ignore #alt text too which may have a hashtag]</p>
<p>Need to ignore html? Done. href="#fine". ignore="This #hashtag in HTML"></p>
<p>Need to support all languages? Done. #kärlek, #爱.</p>

<p> [This is #something else.] </p>

<pre>This is a fork of Colin Devroe's pen from codepen.io. This fork was created on September 5, 2020 by Billy Wilcosky. The license is MIT, but please leave this notice intact. If you fork and make improvements simply add your name and date to this notice which gives credit to all current/past folks who have worked on this. Finally, the best place to keep this notice is where you see it now at the top of the JavaScript code. Thank you. Namaste.</pre>
body {
  background:#f1f1f1;
  margin:2em;
  color:#222;
  font-family:courier;
}

a {
  font-weight:bold;
}

pre {
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}
/* 
This is a fork of Colin Devroe's pen from codepen.io. This fork was created on September 5, 2020 by Billy Wilcosky. The license is MIT, but please leave this notice intact. If you fork and make improvements simply add your name and date to this notice which gives credit to all current/past folks who have worked on this. Thank you. Namaste.
*/

(function (win,doc) {
  'use strict';
  var victims = document.querySelectorAll('p');
for( var i = 0; i < victims.length; i++ ) {
  if( victims[i].hasChildNodes ) {
    var padLeft = document.createTextNode( " " );
    var padRight = document.createTextNode( "" );
    victims[i].appendChild( padRight );
    victims[i].insertBefore( padLeft, victims[i].firstChild );
  }
}
  var siteURL = '/',
      entries = doc.querySelectorAll('p'),
      i;
  if ( entries.length > 0 ) {
    for (i = 0; i < entries.length; i = i + 1) {
      if((entries[i].innerHTML.indexOf("]") == -1)       
&& (entries[i].innerHTML.indexOf("=") == -1)) {
      entries[i].innerHTML = entries[i].innerHTML.replace(/((?!([\S]))[\S\s])#(\p{L}+)/gu,' <a href="'+siteURL+'?q=$3" class="hashlink" title="Find more posts tagged with $3">#$3</a>');
    }
   } 
}
}(this, this.document));

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.