Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > SM::ToHtml does not convert urls to hyperlinks

Reply
Thread Tools

SM::ToHtml does not convert urls to hyperlinks

 
 
Shri Borde
Guest
Posts: n/a
 
      05-19-2009
I am trying to use my own output formatter with SimpleMarkup. Things seems =
to work, except for hyperlinks not working as expected. I tried to use SM::=
ToHtml to simplify things, and even if does not deal with hyperlinks. Here =
is the code snippet I am using.

require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'
s =3D "This is *bold*. These are urls - www.foo.com<http://www.foo.com> , h=
ttp://www.foo.com , foo[http://www.foo.com]"
p =3D SM::SimpleMarkup.new
puts p.convert(s, SM::ToHtml.new)

The output of this is as shown below. The word "bold" was surrounded by the=
<b> tag, but the urls were not surrounded with <a href> tags.

<p>
This is <b>bold</b>. These are urls - www.foo.com<http://www.foo.com> , htt=
p://www.foo.com , foo[http://www.foo.com]
</p>

Is there a way to make this happen?

Regards,
Shri



 
Reply With Quote
 
 
 
 
Eric Hodel
Guest
Posts: n/a
 
      05-19-2009
On May 18, 2009, at 23:30, Shri Borde wrote:

> I am trying to use my own output formatter with SimpleMarkup. Things
> seems to work, except for hyperlinks not working as expected. I
> tried to use SM::ToHtml to simplify things, and even if does not
> deal with hyperlinks. Here is the code snippet I am using.
>
> [...]


You should use RDoc::Markup from RDoc 2. RDoc 1's SM is no longer
maintained.

As described in ri RDoc (for RDoc 2), valid URL formats are:

> * Hyperlinks to the web starting http:, mailto:, ftp:, or www.
> are recognized. An HTTP url that references an external image
> file is converted into an inline <IMG..>. Hyperlinks starting
> 'link:' are assumed to refer to local files whose path is
> relative to the --op directory.
>
> Hyperlinks can also be of the form label[url], in which case the
> label is used in the displayed text, and url is used as the
> target. If label contains multiple words, put it in braces:
> {multi
> word label}[url].
>
> Example hyperlinks:
>
> link:RDoc.html
> http://rdoc.rubyforge.org
> (E-Mail Removed)
> {RDoc Documentation}[http://rdoc.rubyforge.org]
> {RDoc Markup}[link:RDoc/Markup.html]


So, adjusting your input to fit:

$ echo 'This is *bold*. These are urls - http://www.foo.com, foo[http://www.foo.com
]' | rdoc --pipe
<p>
This is <b>bold</b>. These are urls - <a
href="http://www.foo.com">www.foo.com</a>, <a
href="http://www.foo.com">foo</a>
</p>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JDBC URLs ...not really URLs? Adam Monsen Java 11 02-08-2009 08:14 PM
Converting Relative URLs into Absolute URLs Nathan Sokalski ASP .Net 1 08-12-2008 07:03 AM
Converting URLs to clickable hyperlinks using Javascript Jason Javascript 2 01-18-2007 07:53 PM
dynamic URLS convert to static URLS for search engines Steve T. ASP .Net Web Services 7 03-04-2004 03:16 PM
Distinguish text URLs from non-text URLs? Kaidi Java 5 01-04-2004 10:15 AM



Advertisments