在HTML/XML源代码的某些属性字符串(如src或href)中添加换行符 [英] Adding a linebreak in some attribute string(like src or href ) in HTML / XML source

查看:163
本文介绍了在HTML/XML源代码的某些属性字符串(如src或href)中添加换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提高可读性并管理这样的HTML源代码

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"

推荐答案

就是这样:

<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>

好吧,秘密成分在这里是在字符串中使用可靠的 tab 而不是空格的! 解析器会过滤掉它们,然后您会得到一些有效的网址.

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.

这篇关于在HTML/XML源代码的某些属性字符串(如src或href)中添加换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆