Generating html with batch .. escape quotes

时光总嘲笑我的痴心妄想 提交于 2019-11-28 14:16:39

You need to escape all the CMD reserved characters < > | ^ ( ) and & with a caret ^.

A couple of comments

  1. don't escape the reserved chars if they are inside quotes
  2. don't need to escape ( and ) if they are not in IF or FOR or inside another parentheses block.

a more complete example is

echo ^<!DOCTYPE HTML PUBLIC^> >index.html
echo ^<html^> >>index.html
echo ^<!-- more content --^> >>index.html
echo ^<!-- you don't need to escape ( ) outside blocks --^> >>index.html
echo ^<!-- don't escape inside quotes "&" --^> >>index.html
echo ^</html^> >>index.html
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!