I have a file ga-code.txt which contains analytics code.
I want to use phing in a build to replace this token #ga-code# in index.php with the contents of ga-code.txt
Is this possible with phing?
Yes, I can do it with Phing's replacetokenswithfile
The following would replace html comment <!--##ga-code##--> with the contents of a file named ga-code.txt
<replacetokenswithfile begintoken="<!--##" endtoken="##-->" dir="${builddir}/production/" postfix=".txt" translatehtml="false" />
Related
I need to create a regex Custom Redirect in Blogger. The purpose is to redirect all HTML archives to somewhere else.
Currently I'm using the following in Settings / Search preferences / Custom Redirects:
From:/2018_11_21_archive.html
To:/p/somewhere_else.html
Permanent:Yes
The problem is that this method requires to add every date, and that's not acceptable.
/2016_10_21_archive.html
/2016_10_22_archive.html
/2016_10_23_archive.html
/2017_07_10_archive.html
/2017_07_10_archive.html
/2017_07_10_archive.html
/2018_11_21_archive.html
/2019_11_21_archive.html
...
So far I've tried this regex with no success:
From:/2018_(.*)
To:/p/somewhere_else.html
Permanent:Yes
Blogger custom Redirects does not support regex.
But I have a solution for you, use this code, and put it after <head>
<b:if cond='data:view.isArchive and data:view.url contains "_archive"'>
<b:with value='"https://www.example.com/p/somewhere_else.html"' var='destination'>
<script>window.location.replace("<data:destination/>")</script>
<noscript><meta expr:content='"0; URL=" + data:destination' http-equiv='refresh'/></noscript>
</b:with>
</b:if>
You have to escape the "/" character! Just insert a "\" before.
This line must be like this:
From:\/2018_.*
But be aware that this way only /2018_11_21_archive.html will match.
If you need ALL dates as you mentioned, I recommend this regex below:
\/([12]\d{3}_(0[1-9]|1[0-2])_(0[1-9]|[12]\d|3[01]))_archive\.html
I have a string which I need to send in an xml node to a third party application. That string is then parsed through a html parser over there. The string can have html, but problem occurs with non html tags. For example
<cfset str = "This mail was <b>sent</b> by Jen Myke <jmyke#mail.com> on June 20th.<br/> Click on <a href='http://google.com'>this link</a> for more information.">
There can be non-utf characters too in the string, which also cause issues but I found a old blog post which can help remove non-utf.
<cfset str = reReplace(str, "[^\x20-\x7E]", "", "ALL")>
But I am unable to figure out how I can remove html look alikes.
Try wrapping the string with encodeForXML(). This should encode any non-ASCII character for use within an XML node.
<node>#encodeForXml(str)#</node>
If you need to pass data in an attribute, then
<node attr=#encodeForXmlAttribute(str)#"/>
Edit: You can try using getSafeHTML() before encoding the rest of the string. This will remove HTML tags from a string using an XML configuration file to set your AntiSamy settings. Check the docs for more info.
Try replacing
< to <
> to >
I am working on cleaning up text within a google doc. The challenge is that the copy contains HTML markup and I am trying to remove it to be left with clean text.
I have created the following, but it seems to remove only the first instance of HTML code in the cell, how do I get it all out?
= regexreplace(C9,"\<[a-zA-Z0-9-?]*\>","")
try this regular expression :
= regexreplace(C9,"<.*?>","")
=REGEXREPLACE(C9; "</?\S+[^<>]*>";"")
Or
=REGEXREPLACE(C9; "</?\S+[^<>]*>";)
Would do it.
I am trying to convert an XML file to HTML. The XML file has a bunch of HTML tags of the form:
<item><text>Line 1<br/>Line 2<br/>Line 3</text></item>
Ultimately, the output that appears in Internet Explorer is:
<text>Line 1<br/>Line 2<br/>Line 3</text>
When I would like:
Line 1Line 2Line 3
Once I discovered disable-output-escaping, the text rendered properly in IE. Unfortunately, MarkLogic does not support this attribute.
I was able to eliminate the tags altogether using replace(), but I cannot replace the line break tags with an actual new line character.
Does anyone have any ideas on how to either:
1) Render the HTML properly in MarkLogic, or
2) Properly parse the HTML tags in XSLT.
Thanks!
Maybe you want this
let $foo := <item><text>Line 1<br/>Line 2<br/>Line 3</text></item>
return xdmp:unquote($foo/text())
I'm writing an extension for python-markdown, that is supposed to put the text inside some custom tags of mine into a styled div.
I have created a simple Inline Pattern class that encapsulates matched expression in a div tag. My regex is as follows: r'(\{mytag_start\})(.+)(\{mytag_end\})' which then is put inside "^(.*?) --- (.*?)$" by the markdown.inlinepatterns.Pattern class upon compilation, so that the compile method is called as re.compile("^(.*?)%s(.*?)$" %r'(\{mytag_start\})(.+)(\{mytag_end\})').
At a first glance this does seem to do the trick, however I've noticed that all line breaks need to be hardcoded as <br> tags.
So
{mytag_start}This code<br>
will work{mytag_end}
However, the following code breaks the entire markdown
{mytag_start}This code
will not{mytag_end}
So instead I just get the entire above block unprocessed in plain text.
I tried supplying re.MULTILINE and re.DOTALL to the re.compile but it didn't help. Any ideas?
EDIT: Here is a sample extension file that exhibits the aforementioned problems. I then load the extension in my django template using {{ content:"mdx_MyExtension"}}.
Try using a non-greedy operator (+immediately followed by ?) :
r'(\{mytag_start\})(.+?)(\{mytag_end\})'
Full regex :
^(?:.*?)(\{mytag_start\})(.+?)(\{mytag_end\})(?:.*?)$
Flags :
DOTALL, IGNORECASE, MULTILINE
Data test :
blah
blash
<h1>Title</h1>
{mytag_start}This code<br>
will work{mytag_end}
<b>bold</b>
{mytag_start}This code
will not{mytag_end}
Output :
# Run findall
>>> regex.findall(string)
[(u'{mytag_start}', u'This code<br>\nwill work', u'{mytag_end}'), (u'{mytag_start}', u'This code\n\nwill not', u'{mytag_end}')]