Remove white space between html tags php

684 views Asked by At

I have a problem at converting markdown source into other formats using Pandoc. The whole problem occurs when in markdown is located html; when there are some spaces between 2 html tags, it isn't converted correctly. So what I need is to check the whole markdown source and remove all whitespaces between 2 different html tags, e.g.

here is some text in 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; the output after the replacement should look like:

here is some text in 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.

1

There are 1 answers

1
Vishal J On

You can use CSS property white-space:pre-wrap; . Whitespace will be preserved by the browser. Text will wrap when necessary, and on line breaks