Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <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>
              
            
!

CSS

              
                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;
}
              
            
!

JS

              
                /* 
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));
              
            
!
999px

Console