special character parsing in handlebar using triple braces - handlebars.js

I have json in which for a key there is HTML code. In that html code there is special char ($ - dollar).
{
"output": {"agreementText": "test data",
"edgeTerms": [
{
"edgeDeviceName": "Apple® iPhone® 6 Plus 16GB in Gold",
"deviceLabel": null,
"edgeTermsAndCondition": "<h3>RETAIL INSTALLMENT SALE AGREEMENT / RETAIL INSTALLMENT OBLIGATION — SUBJECT TO STATE REGULATION</h3> <p>Price $59 and discount $2</p> "
}
]
}
}
When i am trying to paint json data in html using triple curly braces for HTML parsing like
{{{edgeTermsAndCondition}}}
page goes blank but when i using double curly brace it is painting fine but HTML tags as string, which i don't want.
Please help.

Related

Speech_contexts phrase list not working in google speech.SpeechAsyncClient.streaming_recognize

Unable to make speech_contexts phrase lists work with speech.SpeechAsyncClient in Google Speech to Text..
The transcription works, but the phrase list appears to be ignored.
Is there any config that needs to be in-place?
When Using the speech.SpeechAsyncClient (version 2.17.2 in python) I created a phrase list :
speech_contexts {
phrases: "Burrito"
boost: 10.0
}
speech_contexts {
phrases: "burrito"
boost: 5.0
}
I expected the word audio for 'burrito' to be transcribed as 'Burrito' as text. However it continued to be 'burrito'. Also I tried various phrase lists, but the recognition seems to ignore the phrase lists (same result with/without phrase list).
I verified that the proper speech_context is being sent in the 'streaming_config/Recogntionconfig like this:
Recognitionconfig = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
#encoding = cloud_speech.ExplicitDecodingConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
model="latest_long",
#enable_word_confidence=True,
speech_contexts=speech_contexts #this contains the phrase list
)
#The first message is the following streaming_config and is then followed by audio
streaming_config = speech.StreamingRecognitionConfig(
config=Recognitionconfig, interim_results=True
)
Try using model adaptation to strengthen the accuracy of your transcription results. It also uses RecognitionConfig for the request body. Also follow this format when using SpeechContext.
{
"phrases": [
string
],
"boost": number
}

Firebase & Flutter : Line breaks? [duplicate]

I'm trying to utilize a new line command to create a new line in text. It appears from this issue that this is not possible: New Line Command (\n) Not Working With Firebase Firestore Database Strings
Is this still the case? Assuming so, does Flutter offer any methods with similar functionality to the following that would allow me to work around this?
label.text = stringRecived.replacingOccurrences(of: "\n", with: "\n")
*More context:
Here is a picture of my Firestore string where I entered the data.
I then use a future builder to call this from Firestore and then pass the string (in this case comment) into another widget.
return new SocialFeedWidget(
filter: false,
articleID: document['article'],
article_header: document['article_title'],
userName: document['author'],
spectrumValue: document['spectrum_value'].toDouble(),
comment: document['comment'],
fullName: document['firstName'] + " " + document['lastName'],
user_id: document['user_id'],
postID: document.documentID,
posterID: userID,
);
}).toList(),
In the new widget, I pass it in as a string an feed it via a Text widget as follows:
new Text(
comment,
style: new TextStyle(
color: Color.fromRGBO(74, 74, 74, 1.0),
fontSize: 13.0,
),
),
When it appears, it still has the \n within the string.
In most programming languages if you include \n in a string, it interprets the two characters as a (escape) sequence and it actually stores a single non-printable character with ASCII code 10.
If you literally type \n into a document in the Firestore console however, it stores that exact literal value in the string. So that's two characters \ and n.
These two are not the same. In fact, if you'd want to enter the two-character sequence in a string in most programming languages you'd end up with "\\n". That's two backslashes: the first to start an escape sequence, the second to indicate it's a literal \, and then a literal n.
So if you've stored the literal two-characters \n in a string and you want to display it as a newline in your Flutter app, you need to decode the string back into a single line break character. This is luckily quite simple with:
yourString.replaceAll("\\n", "\n");
For example, this is what I just tested in an app. My document in the Firestore console shows:
And then my code:
var doc = await Firestore.instance.collection("weather").document("sf").get();
var weather = doc.data["condition"]
print(weather);
print(weather.replaceAll("\\n", "\n"));
That first print statement, prints:
Sunny\nI think
While the second prints:
Sunny
I think
Fun fact: when I run this code in Flutter:
Firestore.instance.collection("weather").document("test").setData({ 'condition': "nice\nand\nsunny" });
It shows up like this in the Firestore console:
So it looks like the unprintable \n in the string shows up as a space in the console. I haven't found a way yet to enter a newline into a string in the Firestore console. The API retrieves the line breaks correctly though, so this only affects the Firebase console.
Old thread I know, but for anyone that stumbles here...
If you pass \n to Firestore in a block of text you will indeed not see it if you got look for it in the Firebase console. It is still there though. All you need to do in order to get the new line to work is apply white-space: pre-wrap css to the element where the text is being rendered.
You can use the following in your html style or css:
white-space: pre-line;
line-break: anywhere;
I was able to solve this issue by wrapping the element with a parent with style props white-space: pre-line. Followed by the replaceAll() method:
<div style={{whiteSpace: 'pre-line'}}>
{(content).replaceAll(`<br />`, `\n`)}
</div>

Custom validatation for specific password requirements of company

I am using jQuery-Validation-Engine and hoping to find a custom[passsword] logic that I can add to jquery.validationEngine-en.js that will check for multiple criteria all at once (Requirements: 9 MinChars, 1 UpperCase, 1 LowerCase, 1 Numeric, and 1 SpecialChar). I do not know javascript well enough to even attempt this. I have searched and have been surprised it is not already out there. And possibly it has to be numerous individual ones ? like minSize and maxSize used together in
input type="password" name="password1" id="password1" size="44" maxlength="44"
class="validate[required,minSize[8],maxSize[10],custom[password]]"
This is the EMAIL Check
"email": {
"regex": /^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
"alertText": "* Invalid email address"
What Would the PASSWORD one look like ?
"password": {
"regex": ,
"alertText": "* Invalid password"
I would ideally like it to Alert for the specifc item that is not being input (ie:) No Upper Case Letter, No Numberic, No Spcecial Character, etc.
Thanks In Advance
Well, baptism by fire, but got er done. I had to break these up, which is really what I wanted to do anyways, so that individual Alert Texts could be used for the different criteria required and not one general invalid password message. With the help of regexlib.com I was able to add numerous custom validations within jquery.validationEngine-en.js The minSize[n] and required are already built into the jQuery Validation, so not showing those.
"minLowerAlphaChars": {
// requires at least one lower case alpha character
"regex": /^(.*[a-z].*)/,
"alertText": "* Must include 1 lowercase character"
},
"minUpperAlphaChars": {
// requires at least one UPPER case alpha character
"regex": /^(.*[A-Z].*)/,
"alertText": "* Must include 1 uppercase character"
},
"minSpecialChars": {
// requires at least one SPECIAL character of the list in regex
"regex": /^(?=.*[!##$%&*()_+}])/,
"alertText": "* Must include 1 special character"
},
"minNumberChars": {
// requires at least one NUMERIC
"regex": /^(?=.*\d)/,
"alertText": "* Must include 1 numberic"
},
"noFirstNumber": {
// requires first charecter NOT be NUMERIC
"regex": /^(?!\d)/,
"alertText": "* First Character can not be numberic"
},
Usage;
<input type="password" class="validate[required,minSize[8],custom[minNumberChars],custom[minSpecialChars],custom[noFirstNumber],custom[minUpperAlphaChars],custom[minLowerAlphaChars]]" name="password1" id="password1" size="44">

How do I prevent xdmp:node-delete() from adding whitespace in my xml doc

I am trying to MOVE a node from one xml document to another. Both documents are using the same namespace. I am trying to accomplish this by doing xdmp:node-insert-child() on the first document then xdmp:node-delete() on the second document in a sequence. The problem is that the xdmp:node-delete() is leaving spaces and returns in my xml doc. How can I keep this from happening?
Here is a code example...
let $documentId := 12345
let $newStatus := 123
let $processNode := $PROCESS-DOC//pex:process[(#documentId = $documentId)]
let $newNode :=
element { QName($TNS, 'process') } {
attribute status { $newStatus },
attribute documentId { $processNode/#documentId },
}
return
if ($processNode and $newNode) then
(xdmp:node-insert-child($PROCESS-COMPLETE-DOC/pex:processes, $newNode),xdmp:node-delete($processNode))
else ()
It sounds like the whitespace is held in text nodes on either side of the node you are deleting. You could verify this by inspecting xdmp:describe($processNode/preceding-sibling::text()) and xdmp:describe($processNode/following-sibling::text()). And if you like, you could xdmp:node-delete some or all of those text nodes too.

Html ahref tag in stringbuilder

I am using html
strBody.Append("<span style=\"font-family:Arial;font-size:10pt\"> Hi " + Name + ",<br/><br/> Welcome! <br/><br/>");
strBody.Append("<tr><td style=\"font-weight:bold\">");
strBody.Append("documents for reference are shared in the Account Induction Portal ");
strBody.Append("</td><td>");
strBody.Append("Visit W3Schools<br/><br/>");
strBody.Append("</td><td>");
strBody.Append("</td></tr>");
strBody.Append("<tbody/></table><br/>");
Here href got error i cant include that in string bulider append without error.Pls help on this
you have two sets of parenthesis you must small quote for the url!
strBody.Append("<a href='http://www.w3schools.com'>Visit W3Schools</a><br/><br/>");
or escape like
strBody.Append("Visit W3Schools<br/><br/>"
You don't escape the quotes (") in the following line:
// Replace this
strBody.Append("Visit W3Schools<br/><br/>");
// with either this:
strBody.Append("Visit W3Schools<br/><br/>");
// or use single quotes inside the string:
strBody.Append("<a href='http://www.w3schools.com'>Visit W3Schools</a><br/><br/>");

Resources