complex regex help, convert html image link to cmd - string

hi have thousands of these regex links in html for images
<img src="image.png" alt="" style="zoom:55%;" />
I want to convert them to a quatro (.qmd) markdown links which will look like this
![](image.png){.r-stretch}
I have seen you can use a select in " but am unclear on how to only choose the image.png link but not anything in the documents in quotes. Also unclear is how to do the find and replace part (sed, VS code?)

Try searching
<img\s+(?=[^>]*\bsrc="([^>]*?)")(?=[^>]*\balt="([^>]*?)")?[^>]*\/>
and replacing it with
![$2]($1){.r-stretch}
You may check the test cases here
This will also put anything in alt inside of the square brakets if there's any. If you don't want this behavior, you may just try <img\s+(?=[^>]*\bsrc="([^>]*?)")[^>]*\/> with subsitution of ![]($1){.r-stretch}.

Related

How to write square brackets in markdown

I need to write in my gitlab project wiki page a code block that contains square brackets. Unfortunately the square brackets are turn into a link.
I assume gitlab is using markdown language or the gfm flavor.
This is my code:
```javascript
"{bla, """", [[foo],[]]}"
```
The foo],[ part is turn into a link. So basicaly I need a way to write a square brackets tah are not treated as a link. Surprisingly google doesn't provide any answer for such a trivial issue.
The current answer is that you can't do this. It is a know bug in GitLab, specifically in Wiki pages. GitLab markdown correctly handles square brackets in comments, and code blocks entered in issues, but NOT in wiki pages.
Please add your vote (thumbs up) on the issue to try and get it resolved:
https://gitlab.com/gitlab-org/gitlab-ce/issues/18725
Your (not very appealing) options boil down to these:
Use a single line code entry `"{bla, """", [[foo],[]]}"`
Use another syntax in your code block (e.g. {{), and include a note outside the code block saying to replace {{ with [[, etc - Note that you can use double brackets inside single quote blocks in GitLab Markdown.
Use a screenshot of your code.
None of these are very nice solutions, but all you have at the moment.

Show multiline text in grails page

I'm going mad with this, I need to show a text I got from a textarea in grails 2.3.7 but when I replace \r\n characters for br/ and do an encodeAsHTML() I get the br's every where instead of new lines.
How is it done? this is what I've tried:
${cotizacionInstance.descripcion.encodeAsHTML().replaceAll('\r\n', '<br/>')}
${cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').encodeAsHTML()}
<%=cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').encodeAsHTML()%>
<%=cotizacionInstance.descripcion.encodeAsHTML().replaceAll('\r\n', '<br/>')%>
<%=cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>').decodeHTML()%>
<%=cotizacionInstance.descripcion.decodeHTML().replaceAll('\r\n', '<br/>')%>
I don't like the way it comes out if I use the pre tag, because I loose all responsiveness.
I see that in the google chrome inspector I get my string between double quotes but I don't know how to remove those.
Thanks
There are factors left out of your description which make it impossible to say for sure but one way to get the behavior you are after is to mark the text as raw with something like this...
${raw(cotizacionInstance.descripcion.replaceAll('\r\n', '<br/>'))}
I hope that helps.
You need to esacpe your backslashes:
replaceAll("\\n", "<br/>")

How to replace/remove specific strings from html file using Notepad++?

I've export my bookmarks from FF in to a html file but it's too huge and complicated, so I need to remove some firefox lines from it to make it more lighter and plain.
I can replace basic things in the Notepad++ but I guess I do need some operators for this and I have no idea how to make it work right.
For example here is the line from the file containing a link to Logodesignlove :
Logo Design Love
I need to remove all those tags I don't care about, like LAST_MODIFIED="1256428672", ICON_URI="bunch of digits" ICON="bunch of characters" etc.
And of course I need to remove all those tags in every link in the list.
So I was thinking like use something like "Find all tags LAST_MODIFIED="anynumbers" and replace it with nothing/remove it" - it doesn't work though.
Examle how it should like:
Logo Design Love
So far I removed LAST_MODIFIED and ADD_DATE lines thanks to Aleksandr. So LAST_MODIFIED="\d+" worked just fine. But ICON and ICON_URI are still there. I've tried ICON="\w+" - but it doesn't work. I guess it has something to do with the slashes.
Why look for what you don't want when it's easier to keep hold of what you do want and drop the junk?
(<A HREF=".*?").*?(>.*?>)
with
$1$2
Code edited to suit Notepad++ now I know it doesn't need the special chars escaped. Thanks Aleksandr.
Read up on using regular expressions (the java regex tutorials are a good start http://docs.oracle.com/javase/tutorial/essential/regex/), and try one of the online regex tools to help write and test it, such as this one http://gskinner.com/RegExr/
Eg, remove "LAST_MODIF..." with the regex LAST_MODIFIED="\d+"
Otherwise, you may want an XML-specific tool, or even write an XSL. However, I don't know much about that.

TYPO3: indexed_search and title tag

Is there a way to get a title tag in the search results of indexed_search?
Instead of
Text
there should be
Text
Not a real solution but best I could do:
I think this won't be possible without changing the extension's PHP code. If you do so, copy the extension folder from the systext folder to your typo3conf/ext folder, otherwise you will get in trouble when updating Typo3.
indexed_search seems to have only hardcoded -Tags. You can check this by looking first at the actual HTML output (your search results). Then compare this with the HTML template used. If you have shell access to your server, a grep command might help to locate the correct template. Then try to find the marker. I suppose in your case it's ###TITLE###. Then you have to figure out how the marker is filled. Again a grep command for '###TITLE###' in the folder's extension might help you. Then you will see if the tag is hardcoded or not and how you can change it.
Often the faster solution is to use the template object browser and to try to find a piece of TypoScript below plugin.indexed_search which could be responsible what you want to change.
Unfortunately in your case both didn't help. For some strange reason, '###TITLE###' isn't contained anywhere in the the indexed_search extension.
A very ugly workaround would be to use javascript or jquery to insert the attribute.

How do I replace quotes in XSLT with their HTML entities?

This is related to my previous question -" Manipulate the output of <xsl:apply-templates>".
I want to ask about the specific problem I am looking to address.
How do I replace quotes in XSLT with their HTML entities. I want to eventually pass it to Javascript variable with special characters escaped.
You may want to have a look at the Google code project xml2json-xslt, especially the xml2js.xslt template. Perhaps your answer lies in there.

Resources