Answer the question
In order to leave comments, you need to log in
How to copy the text from the page along with the design?
I’m not the only one who probably faced the question of how to copy from the page not just “plain text”, but at the same time keep the formatting - highlighting with color, italic, etc.?
The problem is complicated by the fact that the source code of the page can be different. It may be html, or it may be bb-code. Plus, the output may also need one or the other.
That is, the problem boils down to the following:
1. Extraction of the original, "raw" text.
2. Determining the formatting rules used in this particular case.
3. Clarification on which formatting rules should be replaced by those used in the source.
4. Creating text with the formatting rules we need.
I'll explain with an example.
Let's say you need to copy a piece of news text from lenta.ru for a root tracker and vice versa.
On lenta.ru , the text is formatted using html tags:
... Об этом сообщает <a href="http://www.afp.com/" target="_blank">Agence France-Presse</a> со ссылкой на газету The Beijing Times. Наводнение в Пекине было вызвано ливневыми дождями, признанными самыми сильными в регионе за последние 60 лет.
<p>
It seems like html is also used on the rutracker, but the text style is tied to classes:
<span class="post-b">Похоже, космос стремительно переходит из сферы государственных интересов в сферу интересов частных. ... </span>
Accordingly, if you copy from lenta.ru to the rutracker , you just need to convert html to bb-code:
<a href="http://www.afp.com/" target="_blank">Agence France-Presse</a>
it will become [url=http://www.afp.com/]Agence France-Presse[/url]
A for in order to from the rutracker to lenta.ru - you have to bite <span class="post-b">...</span>
and turn it into <b>...</b>
In general, the idea is clear, I hope.
I searched the Internet for ways to implement this mechanism and found only 2 plugins for Firefox that implement something similar. The first allows you to copy the source code "under the selected text" (Copy HTML ). The second one allows you to copy the selected text with the replacement of the html markup with the BBCode markup (and then somehow uncertainly, in my opinion).
People, confess, how do you solve such problems? Maybe there are Greasemonkey scripts or fox plugins? I am ready even to use software. If only there was an opportunity to somehow configure the mechanism of such copying “with replacement”.
Maybe you can build a chain of online services like Cool HTML to BBCode Converter ?
Py Sy
But sometimes you have to copy text from forum to forum, and the engines are different. For example, on one forum the left offset is indicated with the help of bbcod'a
[left]...[/left],
on the other -
[align=left] [/align].
Answer the question
In order to leave comments, you need to log in
Autocorrect script?
For example bash function (or in script)
cat > /tmp/filetemp
echo "Конвертированный текст"
sed "s/[старый]/[новый]/g" /tmp/filetemp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question