[p2pu-dev] jsFiddle and Syntax Highlighting

Dan Diebolt dandiebolt at gmail.com
Fri Sep 16 16:55:44 UTC 2011


I am fairly certain that the problem with the jsFiddle embed is in the
regular expression matching embedly uses to parse the ebmeded url. jsFiddle
URLs can have a wide range of forms as they communicate the configuration of
the fiddle using extra url paths. As a preliminary investigation I sent an
inquiry to the jsFiddle mailing list and perhaps Zalun et al will come up
with an answer. Then I will contact embed.ly and hopefully they will get
jsFiddle on the provider list.

==========================================

A platform I work with (p2pu.org) has attempted to use embed.ly to come up
with a shortcode to embed jsFiddles into their platofrm via their
configuration of CKEditor. Here is an example of the embed shortcode that
works:

[embed:http://jsfiddle.net/dandiebolt/agaCq/]

Although jsFiddle is not on Embedly's provider list

http://api.embed.ly/v1/api/services

various forms of the jsFiddle URL do embed. I am not sure why that happens
but I suspect that the reason it does not embed in other cases is because
they are using a overly simplified regular expression to match jsFiddle
URLs. These details may not be to interesting to you but I would like to
pose the independent question as to what regular expression does match a
jsFiddle URL taking into account all the features a jsFiddle may have:

   - anonymous fiddles (no user)
   - characters encoding the jsFiddle ID
   - jsFiddle versions
   - stylesheets
   - show
   - default embed with no tabs specified
   - embed with tabs specified.
   - dependancies

Here is my crude attempt to write a regexp for a jsFiddle URL with various
capturing parentheses tossed in:

/
 (jsfiddle\.net\/)
 ([a-zA-Z0-9]\/)?
 ([a-zA-Z0-9]\/)
 (show\/|embedded\/((html|css|js|resources|result){0,5}\/([a-zA-Z0-9])?\/)?
/

I have no idea what characters are allowed for the jsFiddle ID or user names
so I just specified alphanumerics. Also I overlooked version numbers, &
dependancies when I typed this regexp. Moreover I never tested it.

So if someone wants a challenge I would like to find the regexp that matches
all jsFiddle URLs without getting too anal. The key area is focus on is the
embedded path which can contain tabs (and you apparently can list a tab
twice) because the whole goal of embedly is to embed the jsFiddle URL in an
iframe on blog or cms.

My overall goal is to get embed.ly to support jsFiddle embeds and I will
bird dog that issue but it would be a nice piece of information to have a
regexp for matching any jsFiddle.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p2pu.org/pipermail/p2pu-dev/attachments/20110916/722bb2df/attachment.html>


More information about the p2pu-dev mailing list