Hi,
I'm fetching data from a remote server that returns markdown. I'm using showdownjs in the webview to convert the markdown to HTML. In the b4a code I'm trying to parse youtube links that are not inside an <a>, <iframe> or any other tag. Example markdown return code:
Using Substring, IndexOf, IndexOf2 and Contains string functions, I can get the youtube link. However the server might return mixed markdown with HTML code, or just HTML code (depends on what the user typed):
or he might just link the video, as he doesn't want to embed it.
or, final case here, plain markdown:
What I want to do is check on B4A while parsing and before editing the URL, if it is inside or outside of an HTML tag. However, I fail to do so. Any help?
Here is my B4A code:
Thank you very much for your time
I'm fetching data from a remote server that returns markdown. I'm using showdownjs in the webview to convert the markdown to HTML. In the b4a code I'm trying to parse youtube links that are not inside an <a>, <iframe> or any other tag. Example markdown return code:
B4X:
## Welcome!
This is a B4A Question. Here is a youtube video with info
https://www.youtube.com/watch?v=5871y4BAGqE
Using Substring, IndexOf, IndexOf2 and Contains string functions, I can get the youtube link. However the server might return mixed markdown with HTML code, or just HTML code (depends on what the user typed):
B4X:
## Welcome!
This is a B4A Question. Here is a youtube video with info
<iframe src="https://www.youtube.com/watch?v=5871y4BAGqE" width="50%" frameborder="0" allowfullscreen=""></iframe>
or he might just link the video, as he doesn't want to embed it.
B4X:
## Welcome!
This is a B4A Question. <a href="https://www.youtube.com/watch?v=5871y4BAGqE">Here is a youtube video with info</a>
or, final case here, plain markdown:
B4X:
## Welcome!
This is a B4A Question. ![Here is a youtube video with info](https://www.youtube.com/watch?v=5871y4BAGqE")
What I want to do is check on B4A while parsing and before editing the URL, if it is inside or outside of an HTML tag. However, I fail to do so. Any help?
Here is my B4A code:
B4X:
Sub LinkParser(PostBody As String)
Dim url As String
Do While PostBody.Contains("https://")
url=PostBody.SubString2(PostBody.IndexOf("https://"),PostBody.IndexOf2(" ",PostBody.IndexOf("https://")))
'This is where I want to check if "url" is inside a tag (HTML or markdown).
'If it is, do nothing, it will be parsed by markdown parser.
'If it's not, then proceed with the following commands I have truncated to save space
Loop
Log(url)
End Sub
Thank you very much for your time