Убрать теги p и span из содержимого HTML и переформатировать HTML, чтобы теги p использовались правильно? - PullRequest
0 голосов
/ 28 марта 2012

У меня есть несколько проблем с форматированием cleditor , которое, как представляется, зависит от браузера.

Он выполняет две вещи:

  • Добавление случайного<span> теги с определенным классом (Apple-type-span)
  • Добавление <span> тегов с атрибутом font-size: 10pt;
  • Иногда добавляется <p> тегов, иногда нет

Я хотел бы удалить содержимое всех тегов <span>, <p> и <br />, а затем правильно отформатировать содержимое.

Вот несколько примеров HTML Iхотелось бы изменить:

<p>
    <div>
        <div>
        This species is widely-distributed in lowland, coastal regions of Togo, Benin and Nigeria as far as the Cross River delta, and occurs at some inland localities along the lower Niger River. Populations in Cameroon, Equatorial Guinea and Gabon are now considered to represent other species.
        </div>
    </div>
</p>

=>

<p>This species is widely-distributed in lowland, coastal regions of Togo, Benin and Nigeria as far as the Cross River delta, and occurs at some inland localities along the lower Niger River. Populations in Cameroon, Equatorial Guinea and Gabon are now considered to represent other species.</p>

<p>
    Provided adequate cover and structure is available this&nbsp;<a href="/glossary/s/species" rel="/glossary/s/species?hover=true" class="link_glossary">species</a>&nbsp;is unfussy with regards to décor with ceramic flowerpots, lengths of plastic piping and other artificial materials all useful additions. A more natural-looking arrangement might consist of a soft, sandy&nbsp;<a href="/glossary/s/substrate" rel="/glossary/s/substrate?hover=true" class="link_glossary">substrate</a>&nbsp;with wood roots and branches placed such a way that plenty of shady spots and caves are formed.&nbsp;
    <br>
    <br>
    The addition of dried leaf litter (beech, oak or Ketapang almond leaves are all suitable) would further emphasise the natural feel and with it bring the growth of beneficial microbe colonies as&nbsp;<a href="/glossary/d/decomposition" rel="/glossary/d/decomposition?hover=true" class="link_glossary">decomposition</a>&nbsp;occurs. These can provide a valuable secondary food source for&nbsp;<a href="/glossary/f/fry" rel="/glossary/f/fry?hover=true" class="link_glossary">fry</a>, while the tannins and other chemicals released by the decaying leaves aid in simulation of naturalistic conditions. Leaves can be left in the&nbsp;<a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true" class="link_glossary">tank</a>&nbsp;to break down fully or removed and replaced every few weeks. A net bag filled with&nbsp;<a href="/glossary/a/aquarium" rel="/glossary/a/aquarium?hover=true" class="link_glossary">aquarium</a>-safe&nbsp;<a href="/glossary/p/peat" rel="/glossary/p/peat?hover=true" class="link_glossary">peat</a>&nbsp;can also be added to the&nbsp;<a href="/glossary/f/filter" rel="/glossary/f/filter?hover=true" class="link_glossary">filter</a>&nbsp;or suspended over the edge of the<a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true" class="link_glossary">tank</a>.
    <br>
    <br>
    Fairly dim lighting is recommended and plant&nbsp;<a href="/glossary/s/species" rel="/glossary/s/species?hover=true" class="link_glossary">species</a>&nbsp;from&nbsp;<a href="/glossary/g/genera" rel="/glossary/g/genera?hover=true" class="link_glossary">genera</a>&nbsp;such as&nbsp;<i>Microsorum</i>,&nbsp;<i>Taxiphyllum</i>,&nbsp;<i>Cryptocoryne</i>&nbsp;and<i>Anubias</i>&nbsp;are best since they will grow under such conditions. A few patches of floating vegetation to diffuse the light even further may also prove effective. Filtration, or at least water flow, should not be very strong and very large water changes are best avoided with 10-15% weekly adequate provided the&nbsp;<a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true" class="link_glossary">tank</a>&nbsp;is lightly-stocked.
</p>

=>

<p>
    Provided adequate cover and structure is available this&nbsp;<a href="/glossary/s/species" rel="/glossary/s/species?hover=true" class="link_glossary">species</a>&nbsp;is unfussy with regards to décor with ceramic flowerpots, lengths of plastic piping and other artificial materials all useful additions. A more natural-looking arrangement might consist of a soft, sandy&nbsp;<a href="/glossary/s/substrate" rel="/glossary/s/substrate?hover=true" class="link_glossary">substrate</a>&nbsp;with wood roots and branches placed such a way that plenty of shady spots and caves are formed.&nbsp;
</p>
<p>
    The addition of dried leaf litter (beech, oak or Ketapang almond leaves are all suitable) would further emphasise the natural feel and with it bring the growth of beneficial microbe colonies as&nbsp;<a href="/glossary/d/decomposition" rel="/glossary/d/decomposition?hover=true" class="link_glossary">decomposition</a>&nbsp;occurs. These can provide a valuable secondary food source for&nbsp;<a href="/glossary/f/fry" rel="/glossary/f/fry?hover=true" class="link_glossary">fry</a>, while the tannins and other chemicals released by the decaying leaves aid in simulation of naturalistic conditions. Leaves can be left in the&nbsp;<a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true" class="link_glossary">tank</a>&nbsp;to break down fully or removed and replaced every few weeks. A net bag filled with&nbsp;<a href="/glossary/a/aquarium" rel="/glossary/a/aquarium?hover=true" class="link_glossary">aquarium</a>-safe&nbsp;<a href="/glossary/p/peat" rel="/glossary/p/peat?hover=true" class="link_glossary">peat</a>&nbsp;can also be added to the&nbsp;<a href="/glossary/f/filter" rel="/glossary/f/filter?hover=true" class="link_glossary">filter</a>&nbsp;or suspended over the edge of the<a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true" class="link_glossary">tank</a>.
</p>
<p>
    Fairly dim lighting is recommended and plant&nbsp;<a href="/glossary/s/species" rel="/glossary/s/species?hover=true" class="link_glossary">species</a>&nbsp;from&nbsp;<a href="/glossary/g/genera" rel="/glossary/g/genera?hover=true" class="link_glossary">genera</a>&nbsp;such as&nbsp;<i>Microsorum</i>,&nbsp;<i>Taxiphyllum</i>,&nbsp;<i>Cryptocoryne</i>&nbsp;and<i>Anubias</i>&nbsp;are best since they will grow under such conditions. A few patches of floating vegetation to diffuse the light even further may also prove effective. Filtration, or at least water flow, should not be very strong and very large water changes are best avoided with 10-15% weekly adequate provided the&nbsp;<a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true" class="link_glossary">tank</a>&nbsp;is lightly-stocked.
</p>

<br>
<p>
    <font class="Apple-style-span" face="Georgia">
        <i>A. cirrhosus</i> is native to the Argentinian portion of the Paraná river drainage but all <i>A.</i> cf. <i>cirrhosus</i> in the hobby are produced commercially.
    </font>
</p>

=>

<p><i>A. cirrhosus</i> is native to the Argentinian portion of the Paraná river drainage but all <i>A.</i> cf. <i>cirrhosus</i> in the hobby are produced commercially.</p>

<p>
    <b>
        <span class="Apple-style-span" style="font-weight: normal; ">
        </span>
    </b>
</p>
<p>
    <b>
        <strong>Temperature</strong>:
    </b>
    [temp]
</p>
<p>
    <b>
        <strong>pH</strong>:
    </b>
    [pH]
</p>
<p>
    <b>
        <strong>Hardness</strong>:
    </b>
    [hardness]
</p>
<p></p>

=>

<p><strong>Temperature</strong>: [temp]</p>
<p><strong>pH</strong>: [pH]</p>
<p><strong>Hardness</strong>: [hardness]</p>

Есть ли способ, которым я могу сделать это быстро и легко?Класс форматирования PHP или аналогичный, который я мог бы использовать, чтобы разобраться в этом для меня?

Это ужасно уродливый код.Я писал в WPSE об использовании другого RTE, но я подозреваю, что cleditor - единственный, который будет работать: (

Заранее спасибо,

...