views:

15

answers:

1

I'm trying to create a safari extension that will place an "Add to BibDesk" link after any text that looks like a BibText entry. BibText entries look like this:

@string{
    foo  = "bar",
    foo2 = "bar2"
} 

I know how to construct the necessary regex, but my question is what's the best way, using javascript, to search all the text on a page for a particular bit of text?

A: 

Get any elements that can contain text nodes (div, p, etc.) using a selector, then for each element search for any BibText entries and replace the matched text with itself PLUS the link that does the work appended to the end.

CD Sanchez
"Any elements that can contain text nodes?" That could literally be anything, couldn't it?
eykanal
@eykanal: Basically. Not all elements though. `img` elements don't have text nodes.
CD Sanchez