var linkify = require('html-linkify'),
  format = require('util').format,
  truncate = require('html-truncate');

module.exports = {
  present: function(text, opts) {
    if (!text) return '<p></p>';

    // wrap in a <p> tag
    if (!opts.skipWrap && text.substring(0, 3) != '<p>')
      text = format('<p>%s</p>', text);

    // make links
    text = linkify(text, {escape: false, attributes: {target: '_blank'}});

    // link hashtags
    text = text.replace(/([^\w]|^)#(\w+)/g, format('$1<a href="/h/search?c=%s&q=%23$2">#$2</a>', opts.communityId));

    if (opts.maxlength)
      text = truncate(text, opts.maxlength);

    return text;
  }
};
@@ -432,16 +432,78 @@
 ashtags%0A
+    // this is not ideal because it hardcodes the search path%0A
     text
@@ -538,23 +538,16 @@
 %5Cw+)/g, 
-format(
 '$1%3Ca hr
@@ -564,13 +564,8 @@
 rch?
-c=%25s&
 q=%252
@@ -581,27 +581,8 @@
 /a%3E'
-, opts.communityId)
 );%0A%0A

make hashtag search non-community-specific