Remove Line Breaks From Cell Content in WordPress

A line break in a table cell is converted to ⟨br ⁄ ⟩ when it is saved. I must remove all line breaks from the cell content else there is excessive space between paragraphs, list items, etc. It makes a large block of content harder to edit than it should be since it is all mushed together.

Is there an option or a workaround to prevent the arbitrary insertion of ⟨br ⁄ ⟩’s in cell content? or is there a way to convert line breaks to false within the table

I would also appreciate hacking the code to reduce it and make it more efficient.

I have looked for online plugins in WordPress to select and remove all HTML files, but I can't find them.

!DOCTYPE html
html lang="en"
head
    meta charset="UTF-8"
    titleTitle/title
/head
body
!-- Codes by HTML.am --

!-- CSS Code --
style type="text/css" scoped
    table.GeneratedTable {
        width:100%;
        background-color:#FFFFFF;
        border-collapse:collapse;border-width:1px;
        border-color:#336600;
        border-style:solid;
        color:#009900;
    }

    table.GeneratedTable {
        convert_line_breaks=false/
    }

    table.GeneratedTable td, table.GeneratedTable th {
        border-width:1px;
        border-color:#336600;
        border-style:solid;
    }

    table.GeneratedTable thead {
        background-color:#CCFF99;
    table id=123 convert_line_breaks=false
    }
/style

!-- HTML Code --
table class="GeneratedTable"
    thead
    tr
        thGwarinpa SEC/th
    /tr
    /thead
    body
    tr
        td
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:100%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thNumber of Chairs/th
                    thNumber of Tables/th
                    thNumber of Classroom Boards/th
                    thCeiling Structure: Status/th
                    thProtection from Rain: Status/th
                /tr
                /thead
                tbody
                captionCLASSROOM ACCESSMENT/caption
                tr
                    td5/td
                    td5/td
                    tdNULL/td
                    tdFull Ceiling/td
                    tdFull Protection/td


                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:70%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thFloor Finishing/th
                    thFirst Aid Boxs/th
                    thFire Extinguishers/th
                    thIllumination/th
                    thVentilation/th
                /tr
                /thead
                tbody
                tr
                    tdUnfinished Cementing/td
                    tdNULL/td
                    tdNULL/td
                    tdFALSE/td
                    tdOpen Roofs/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:100%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thNumber of Learning Subjects Per Day: Status/th
                    thNumber of Missed Subjects Per Day: Status/th
                    thCurriculum Assessments/th
                /tr
                /thead
                tbody
                captionTIMETABLE ACCESSMENT/caption
                tr
                    td2/td
                    td3/td
                    tdpNon Standard/ppRatings:3(poor)/p/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thRatio of One Teacher to Assigned Subjects/th
                    thTeachers Qualifications in Respect to Assigned Subject/th
                    thFrequency of Knowledge Updates/Teachers Training/th
                /tr
                /thead
                tbody
                captionTEACHER ACCESSMENT/caption
                tr
                    tdOne Teacher to Ten Subjects/td
                    tdUnqualified Teachers/td
                    tdNo Updates/Teacher Training/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thTypes of Toilet/th
                    thDaily Cleanness Level of Toilet/th
                    thNumber of Employed Cleaners: Status/th
                /tr
                /thead
                tbody
                tr
                    captionTOILET ACCESSMENT/caption
                    tdpOpen Defecation/ppPit/p/td
                    tdFALSE/td
                    tdONE/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thFrequency /th
                /tr
                /thead
                tbody
                caption Frequency of Class Attendance /caption
                tr
                    tdVery Low/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thRatio/th
                /tr
                /thead
                tbody
                tr
                    tdp50percnt; Closed/pp50percnt; Open/p/td
                /tr
                captionRatio of School Open to School Closed in a Month/caption
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thAir Quality /th
                /tr
                /thead
                tbody
                tr
                    captionAir Quality Assessment in School Environment: Status/caption
                    td20percnt; Clean Air/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thRoad Quality/th
                /tr
                /thead
                tbody
                tr
                    captionRoad Network Assessment to School: Status/caption
                    td80percnt; bad road /td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thInternet Quality/th
                /tr
                /thead
                tbody
                tr
                    captionAccess to Internet: Status/caption
                    tdFALSE/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thComputer Labs/th
                /tr
                /thead
                tbody
                tr
                    captionAccess to a Computer Labs/caption
                    tdFALSE/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thScience Labs/th
                /tr
                /thead
                tbody
                tr
                    captionAccess to a Science Lab/caption
                    tdFALSE/td
                /tr
                /tbody
            /table
            !-- Codes by HTML.am --

            !-- CSS Code --
            style type="text/css" scoped
                table.GeneratedTable {
                    width:30%;
                    background-color:#FFFFFF;
                    border-collapse:collapse;border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    color:#009900;
                }

                table.GeneratedTable td, table.GeneratedTable th {
                    border-width:1px;
                    border-color:#336600;
                    border-style:solid;
                    padding:3px;
                }

                table.GeneratedTable thead {
                    background-color:#CCFF99;
                }
            /style

            !-- HTML Code --
            table class="GeneratedTable"
                thead
                tr
                    thRating--On-Time: [1: Low - 10: Very High]/th
                    thRating--Off-Time: [1: Low - 10: Very High]/th
                /tr
                /thead
                tbody
                tr
                    captionAccess to Electricity/caption
                    tdRating: 20frasl;100/td
                    td20 percnt; availability /td
                /tr
                /tbody
            /table


        /td
    /tr

/body
/html

Topic table line-breaks html Wordpress

Category Web


The <br/> tags are added by wpautop function that is hooked into the_content filter. So you need to unhook it from the page where your table is displayed. There are several ways to do this.

With PHP you can do something like this (change the 'your_page/post_id' with the actual ID)

function wpdg_91929_remove_autop_for_page( $content )
{
    global $post;
    if($post->ID == 'your_page/post_id') {
       remove_filter( 'the_content', 'wpautop' );
    }
    return $content;
}
add_filter( 'the_content', 'wpdg_91929_remove_autop_for_page', 0 );

With jQuery you can do something like this:

<script>
(function($){
   $('.GeneratedTable').each(function(){
      $(this).find('br').remove();
   });
})(jQuery);
</script>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.