A
A
Artur Zayats2013-11-29 19:18:54
JavaScript
Artur Zayats, 2013-11-29 19:18:54

Clicked on a word, how to get an offer?

The essence of the task is as follows, it will be necessary to develop a browser extension, which, among other things, could receive the sentence in which it is located on any web page by the clicked word (well, the word itself in the sentence must be somehow marked).
For example, there is text:

Недавно мне понадобилось реализовать небольшой аудио плеер. Я, по различным причинам, выбрал библиотеку Gstreamer. И вот решил поделиться полученными знаниями. Надеюсь, приведенная ниже информация кому-то будет полезна (очень надеюсь).

You click on the word "share" - the extension should return:
И вот решил **поделиться** полученными знаниями.
It should work primarily with the English language. What problems I foresee:
1 - all kinds of nested tags inside the sentence: b, i, a, strong
2 - quotes and brackets inside the sentence
3 - colon with enumeration - then there can be an ordered or unordered list and this is all one sentence ...
Does anyone have any thoughts? Maybe something already exists? What approaches can be applied here?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2013-11-29
@fornit1917

I don’t understand why tags, quotes, brackets interfere with you? Tags are removed by a single function. The text on the sentences beats on the delimiter ".".

B
bahek2462774, 2013-11-29
@bahek2462774

as an option when loading the page
1) split the entire text into sentences. So that each offer was in a separate span.
2) to get a selection using some kind of race two method ,
well, it will not be difficult to get the whole sentence using it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question