[英]Remove white space between html tags php
I have a problem at converting markdown source into other formats using Pandoc. 我在使用Pandoc将markdown源转换为其他格式时遇到问题。 The whole problem occurs when in markdown is located html;
整个问题在markdown中位于html时发生; when there are some spaces between 2 html tags, it isn't converted correctly.
当2个html标记之间有空格时,则无法正确转换。 So what I need is to check the whole markdown source and remove all whitespaces between 2 different html tags, eg
因此,我需要检查整个markdown源并删除2个不同 html标记之间的所有空格,例如
here is some text in markdown (lorem ipsum) 这是markdown(lorem ipsum)中的一些文本
<table>
<tr>
<td> here is some text</td>
<td>some other text</td>
</tr>
</table>
I'm using Pandoc in php, so I think that when the source of markdown is read in a variable, that could be matched and replaced with some regex
; 我在php中使用Pandoc,因此我认为,当markdown的源代码读入一个变量时,可以将其匹配并用一些
regex
替换; the output after the replacement should look like: 替换后的输出应如下所示:
here is some text in markdown (lorem ipsum) 这是markdown(lorem ipsum)中的一些文本
<table><tr><td> here is some text</td><td>some other text</td></tr></table>
So just when between >
and <
there is nothing else than whitespace, the whitespace should be removed. 因此,只要在
>
和<
之间只有空格,就应该删除空格。
You can use CSS property white-space:pre-wrap;
您可以使用CSS属性
white-space:pre-wrap;
. 。 Whitespace will be preserved by the browser.
空白将由浏览器保留。 Text will wrap when necessary, and on line breaks
文本将在必要时自动换行并换行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.