How to output "<" and ">" symbols to a text file using batch script - html

I created a simple batch script to format some HTML codes that i use on a regular basis. My current workaround is outputting 888 and 999 and going back into the text file and replacing all 888's with a < and all 999's with a >. I know batch uses these symbols and redirects so i wanted to know if there was a way to bypass this. Below is an example.
888div id="bestlinkstop"999
888a href=" " target="_blank"999 888img src=" "999 888/a999
888/div999
changing all 8's and 9's to < and >
<div id="bestlinkstop">
<img src=" ">
</div>
Thanks in advance

You can use the Windows escape character is ^ to escape the brackets.
Something like
echo mystring ^< div id="bestlinkstop" ^> something >>myfile.txt

Related

Adding a signature in pdf in powerapps

i am trying to add a signature in a pdf in powerapps using the peninput field. i add the following in the html file which file is successfully converted in pdf through the flow
<img src='"& JSON(PenInput4.Image; JSONFormat.IgnoreBinaryData) &"'
style='width:80px;height:50px'></img>
but i see this in the pdf a box with an x on the top left corner.
thank you!
The result of the JSON function already includes quotes, so you are "double-quoting" the image source. This is what you have:
<img src='"data:image/png;base64,..."' style='...'></img>
You can either use the double quotes (") that are returned by the JSON function:
"<img src=" & JSON(PenInput4.Image; JSONFormat.IncludeBinaryData) &
" style='width:80px;height:50px'></img>"
Or you if you want to use single quotes (') in your HTML document, you can keep your single quotes and remove the double quotes from the JSON output:
Set(penInputEncodedImage, JSON(PenInput4.Image; JSONFormat.IncludeBinaryData));;
...
"<img src='" &
Mid(penInputEncodedImage, 2, Len(penInputEncodedImage) - 2) &
"' style='width:80px;height:50px'></img>"
Just a final note: you are using JSONFormat.IgnoreBinaryData - the correct flag to be able to encode images should be JSONFormat.IncludeBinaryData. It seems to be working today, but that goes against the documentation so it is a bug that may be fixed someday.

Do you have any function or tools to convert simple html to special code which I like?

I want to convert a simple code to an special code which I like. see this simple code :
<html>
<body>
The content of the document
</body>
</html>
convert to :
<html>\n\t<body>\n\t\t The content of the document \n\t</body>\n</html>
(convert linebreak to \n ; convert tabs to \t ; convert " to \")
And finally put them in one line. just one line.
Can you suggest me a good function or tools for this work?
First to come into mind is Notepad++ for me.
In Macro menu
You can start recording your actions
Replace all linebreaks with \n
Replace all tabs with \t
Replace all " with \"
And save your macro to use whenever you want to use again

What is the right way to escape a bash variable to be correctly expanded in HTML?

I have this piece of code for adding a link to an index.html in a directory based on a timestamp. $(tstampm) is a function that generates a timestamp.
export tstampm=$(tstampm)
echo 'output from sysuser database - <a href="sysuser/model01-$tstampm"</a> <br />' >> /home/sysuser/docs/dbmodels/index.html
The quotes in the href prevent expansion of the bash variable. What is the correct syntax for getting it expanded?
Note that the double quotes for the href are enclosed in single quotes for the echo command itself.
Variables are expanded inside double quotes, they're not expanded inside single quotes.
echo "output from sysuser database - <a href='sysuser/model01-$tstampm'></a> <br />" >> /home/sysuser/docs/dbmodels/index.html
You were also missing the closing > of the <a> tag. And you probably want something between <a> and </a>, so there will be something to click on.
As #Bramar says, and you can directly call your tmstamp as I call the date in the next example:
echo "output from sysuser database - some text <br />"
produces
output from sysuser database - some text <br />

How do I write a ">" into a txt file with batch?

I need to write an html document from a batch file and this document contains the ">" character. When I try to write a ">" character to a file though, it cuts off and doesn't write.
Example -
Echo <HTML> > HtmlDoc.html
The output here to the file would be
<HTML
How do I fix this?
You need to escape the special characters:
echo ^<html^> > HtmlDoc.html
For more information about escapes in batch scripting, read http://www.robvanderwoude.com/escapechars.php

AppleScript: substring to string or format html

I'm working on my applescript right now and I'm stuck here.. Lets take this snippet as an example of html code
<body><div>Apple don't behave accordingly <a href = "http://apple.com>apple</a></div></body>
What I need now is to return the word without the html tags. Either by deleting the bracket with everything in it or maybe there is any other way to reformat html into plain text..
The result should be:
Apple don't behave accordingly apple
Thought I would add an extra answer because of the problem I had. If you want UTF-8 characters to not get lost you need:
set plain_text to do shell script "echo " & quoted form of ("<!DOCTYPE HTML PUBLIC><meta charset=\"UTF-8\">" & html_string) & space & "| textutil -convert txt -stdin -stdout"
You basically need to add the <meta charset=\"UTF-8\"> meta tag to make sure textutil sees this as an utf-8 document.
How about using textutil?
on run -- example (don't forget to escape quotes)
removeMarkup from "<body><div>Apple don't behave accordingly apple</div></body>"
end run
to removeMarkup from someText -- strip HTML using textutil
set someText to quoted form of ("<!DOCTYPE HTML PUBLIC>" & someText) -- fake a HTML document header
return (do shell script "echo " & someText & " | /usr/bin/textutil -stdin -convert txt -stdout") -- strip HTML
end removeMarkup
on findStrings(these_strings, search_string)
set the foundList to {}
repeat with this_string in these_strings
considering case
if the search_string contains this_string then set the end of the foundList to this_string
end considering
end repeat
return the foundList
end findStrings
findStrings({"List","Of","Strings","To","find..."}, "...in String to search")