Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
887 views
in Q2A Core by
closed by

Maybe I have overseen, but is there an option to parse posted http links to be clickable?

E.g. http://www.question2answer.org/

should become http://www.question2answer.org/

core or plugin?

closed with the note: fixed in q2a v1.5.3

1 Answer

0 votes
by

This should be done automatically. It definitely is in the plain text editor and Markdown editor.

Let me just test here... http://www.google.com

EDIT: yep worked fine. There is an option in the Admin, "Detect and link URLs in posts" so maybe you unticked that?

EDIT 2: Ha, it linked the URL the first time, but decided not to the second time. No idea why that is.

by
edited by
"Detect and link URLs in posts" is ticked. Strange!
I also tried to find a way to enable automatic linking in CKEditor, no luck.

As you see here in the source of this page, the link abovie is not parsed but outputs standard:
<p>    E.g. http://www.question2answer.org/</p>

Edit: just see, the link in this comment gets parsed, wow!
by
If there is any styled text in the post, then the post is stored in the database as HTML, and links are not automatically parsed, because it's hard to parse links written as plain text within HTML markup. But I'll look into this for the next maintenance release.
by
Maybe there is an option on the CKeditor itself to automatically link URLs (before the post is submitted)?
by
I checked that already but could not find it. There were only posts about IE parsing URLs automatically (mentioned as bug in their forums, lol)...
by
Automatic linking of URLs is now live on this site. The fix will be rolled into Q2A 1.5.3. If you want it now, go to qa-viewer-basic.php before this line:

} elseif ($format=='') {

... and paste in the following code ...

if (@$options['showurllinks']) { // we need to ensure here that we don't put new links inside existing ones
  require_once QA_INCLUDE_DIR.'qa-util-string.php';
  
  $htmlunlinkeds=array_reverse(preg_split('|<[Aa]\s+[^>]+>.*</[Aa]\s*>|', $html, -1, PREG_SPLIT_OFFSET_CAPTURE)); // start from end so we substitute correctly
  
  foreach ($htmlunlinkeds as $htmlunlinked) { // and that we don't detect links inside HTML, e.g. <IMG SRC="http://...">
    $thishtmluntaggeds=array_reverse(preg_split('/<[^>]*>/', $htmlunlinked[0], -1, PREG_SPLIT_OFFSET_CAPTURE)); // again, start from end
    
    foreach ($thishtmluntaggeds as $thishtmluntagged) {
      $innerhtml=$thishtmluntagged[0];
      
      if (is_numeric(strpos($innerhtml, '://'))) { // quick test first
        $newhtml=qa_html_convert_urls($innerhtml, qa_opt('links_in_new_window'));
        
        $html=substr_replace($html, $newhtml, $htmlunlinked[1]+$thishtmluntagged[1], strlen($innerhtml));
      }
    }
  }
}
...