Adding a linebreak in some attribute string(like src or href ) in HTML / XML source

断了今生、忘了曾经 提交于 2019-12-02 06:27:56

问题


I like to improve readability and managing some HTML source code like this

<iframe src= "https://www.google.com/recaptcha/api2/anchor?k=6LeaOiITAAAAAF_A-e9qjM6TCgdt4-rqixnkkatL                                   &co=aHR0cDovL3BsYXkuc3BvdGlmeS5jb20                                 &hl=de&v=r20160802154045&theme=dark&size=normal&cb=ap65yyq41qhy" title="reCAPTCHA-Widget" ...

I mean line breaking attribut names is the first step:

<iframe src= "https://www.google.com/recaptcha/api2/anchor?k=6LeaOiITAAAAAF_A-e9qjM6TCgdt4-rqixnkkatL                                   &co=aHR0cDovL3BsYXkuc3BvdGlmeS5jb20                                 &hl=de&v=r20160802154045&theme=dark&size=normal&cb=ap65yyq41qhy"
        title="reCAPTCHA-Widget" 

However is there a way of breaking down that long URL that i'll look somehow like this:

   "https://www.google.com/recaptcha/api2/anchor" +
        "?k=6LeaOiITAAAAAF_A-e9qjM6TCgdt4-rqixnkkatL" +
        "&co=aHR0cDovL3BsYXkuc3BvdGlmeS5jb20" +
...
        "&size=normal" +
        "&cb=ap65yyq41qhy"

回答1:


That's it:

<iframe 
	src = "
		https://www.google.com/recaptcha/api2/anchor
			?	k	=	6LeaOiITAAAAAF_A-e9qjM6TCgdt4-rqixnkkatL
			&	co	=	aHR0cDovL3BsYXkuc3BvdGlmeS5jb20
			&	hl	=	de
			&	v	=	r20160802154045
			&	theme	=	dark
			&	size	=	normal
			&	cb	=	ap65yyq41qhy
		"
	></iframe>

Well the secret ingredient here is to use solidly tab's instead of space when you are inside some string! The parser will filter them out and you get some working url.



来源:https://stackoverflow.com/questions/38874711/adding-a-linebreak-in-some-attribute-stringlike-src-or-href-in-html-xml-sou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!