feed text parser - html

I'm getting text from an API and it's something like following:
text = 'replied to #james and he was visiting this http://some-site.com/another/something/../ so what you think about it';
How can I parse this text and make links as html links and #james as html links also, but with their own href values.
Does anyone know any function that already does that or can someone paste their own function here please?

Depends on the language you are using (it's not clear from your question). But you can transform your links and #text into clickable URLs with regular expressions.
This google search will point you in the right direction.

Related

HTML: href of anchor. How to concatenate instead of replace?

I am in the page
www.myWebsite.com/registration?type=lookfor
And in the menu I have an anchor to change the language.
English
If I click on this anchor, I will be redirect to
www.myWebsite.com/registration?lang=en
... but the correct result would be
www.myWebsite.com/registration?type=lookfor&lang=en
I could easily elaborate a javascript solution, but I would like to have a simple HTML solution, if there is any.
English
Try this html code for redirect with two query strings

Do you know how to make Hebrew JSON file show correct characters in HTML page?

I am having a problem in showing Hebrew letters on my HTML page. I am using (as far as I know maybe I'm wrong) JSON file from here:
https://getbible.net/json?scripture=Psa%20119&version=bhs
I want it to look like this one:
https://www.biblegateway.com/passage/?search=Ps.119&version=WLC
But I still get only this: u05d0\u05b7\u05e9\u05c1\u05b0\u05e8\u05b5\u05d9 \u05e0\u05b9\u05e6\u05b0\u05e8\u05b5\u05d9 \u05e2\u05b5\u05d3\u05b9\u05ea\u05b8\u05d9\u05d5
I mean I want it to show all Hebrew symbols. Does anyone know how to fix that on the HTML page? Thank you.
I don't know what framework library you are using but it should be displayed correctly unless you or the library you are using escapes the unicode characters a second time ("\u05d0" becoming "\\u05d0").
var verse ={"verse_nr":1,"verse":"\u05d0\u05b7\u05e9\u05c1\u05b0\u05e8\u05b5\u05d9 \u05ea\u05b0\u05de\u05b4\u05d9\u05de\u05b5\u05d9\u05be\u05d3\u05b8\u05e8\u05b6\u05da\u05b0 \u05d4\u05b7\u05d4\u05b9\u05dc\u05b0\u05db\u05b4\u05d9\u05dd \u05d1\u05bc\u05b0\u05ea\u05b9\u05d5\u05e8\u05b7\u05ea \u05d9\u05b0\u05d4\u05d5\u05b8\u05d4\u05c3\r\n"};
document.getElementById("content").textContent = verse.verse;
<div id="content"/>

How do web browsers implement a text search?

I would like to build an application that contains HTML web control, and enables searching and highlighting multiple phrases in the html area, like it's implemented in web browsers today.
The main idea is to make the search ignore the html special tags, and refer only to the real text (the inner html).
I know that the solution will include editing the DOM, but I'm not sure how this could be implemented.
I searched a lot over the net, and I read also the post of Zavael, but unfortunately I couldn't find any suitable answer. Any answer, example or direction will be appreciated.
If you are referring to an inline search of HTML content within the page: firstly I would say that it probably isn't a good idea. You shouldn't supplant the browser's native functionality. Let users do things the way they are used to. Keep the experience consistent across different websites.
However, if you need this for some niche purpose I don't think it would be that hard.
jQuery could achieve it. Just a very rough start:
//As you type in the search box...
$("#search_box").change(function() {
//...you search the searchable area (maybe use some regex here)
$("#search_area").html();
});
EDIT: Questioner asked if I can elaborate on the code.
//As you type in the search box...
$("#search_box").change(function() {
//This part of the code is called when the contents of the search box changes
//This is the contents of the searchable area:
$("#search_area").html();
//This is the contents of the search box:
$(this).val();
//So you could perform a function here, like replacing the occurences of the
//search text with a span (you could use CSS to highlight the span with a
//background colour:
var html_contents = $("#search_area").html();
var search_tem = $(this).val();
$("#search_area").html(html_contents.replace(search_term, '<span class="highlight">'+search_term+'</span>'));
});
Please note that in the above example, the Javascript 'replace' function will only replace the first occurence. You need to use a regular expression in the first paramater to replace all. But I don't want to write all the code for you ;)

Print HTML on webpage

I want to print some java, jsp code on webpage in an indented format.
Is There a tool that would do it, right now I have to use &nbsp, &lt, &gt to get it done, which is very painful
You could just use the <pre> tag...
If you have access to a text editor, you could just use "Find & Replace..."
Just replace:
< with <
> with >
(two spaces) with
You would have to find the dynamic way of storing and printing the text for example with the combination of javascript and php you can easily achieve this with the help of free and open text editor like WYSIWYG Editor
Have a look at this URL : http://www.openwebware.com/
this can provide a complete solution to you. and embedding on your website should not be a problem, just google something like embedding WYSIWYG Editor etc. you can always find many good tutorial that explain step by step how to do this..
hope this helps you..

Automatically make links to URLs

Basically at the moment I have:
http://link.com - plain text
I would like:
http://link.com
Is it possible to automatically add 'a href'?
If so how should I go about doing it?
Yes, you could parse your text on load with javascript. By using the appropriate regular expression, just replace each link with the anchored link version.
text.replace(**link regular expression**, "$1");
Note: The syntax is probably not right, but you get the idea.