0

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">
    <title>Title</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>
        <th>Gwarinpa 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>
                    <th>Number of Chairs</th>
                    <th>Number of Tables</th>
                    <th>Number of Classroom Boards</th>
                    <th>Ceiling Structure: Status</th>
                    <th>Protection from Rain: Status</th>
                </tr>
                </thead>
                <tbody>
                <caption>CLASSROOM ACCESSMENT</caption>
                <tr>
                    <td>5</td>
                    <td>5</td>
                    <td>NULL</td>
                    <td>Full Ceiling</td>
                    <td>Full 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>
                    <th>Floor Finishing</th>
                    <th>First Aid Boxs</th>
                    <th>Fire Extinguishers</th>
                    <th>Illumination</th>
                    <th>Ventilation</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>Unfinished Cementing</td>
                    <td>NULL</td>
                    <td>NULL</td>
                    <td>FALSE</td>
                    <td>Open 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>
                    <th>Number of Learning Subjects Per Day: Status</th>
                    <th>Number of Missed Subjects Per Day: Status</th>
                    <th>Curriculum Assessments</th>
                </tr>
                </thead>
                <tbody>
                <caption>TIMETABLE ACCESSMENT</caption>
                <tr>
                    <td>2</td>
                    <td>3</td>
                    <td><p>Non Standard</p><p>Ratings: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>
                    <th>Ratio of One Teacher to Assigned Subjects</th>
                    <th>Teachers Qualifications in Respect to Assigned Subject</th>
                    <th>Frequency of Knowledge Updates/Teachers Training</th>
                </tr>
                </thead>
                <tbody>
                <caption>TEACHER ACCESSMENT</caption>
                <tr>
                    <td>One Teacher to Ten Subjects</td>
                    <td>Unqualified Teachers</td>
                    <td>No 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>
                    <th>Types of Toilet</th>
                    <th>Daily Cleanness Level of Toilet</th>
                    <th>Number of Employed Cleaners: Status</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>TOILET ACCESSMENT</caption>
                    <td><p>Open Defecation</p><p>Pit</p></td>
                    <td>FALSE</td>
                    <td>ONE</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>
                    <th>Frequency </th>
                </tr>
                </thead>
                <tbody>
                <caption> Frequency of Class Attendance </caption>
                <tr>
                    <td>Very 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>
                    <th>Ratio</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td><p>50&percnt; Closed</p><p>50percnt; Open</p></td>
                </tr>
                <caption>Ratio 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>
                    <th>Air Quality </th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>Air Quality Assessment in School Environment: Status</caption>
                    <td>20&percnt; 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>
                    <th>Road Quality</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>Road Network Assessment to School: Status</caption>
                    <td>80&percnt; 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>
                    <th>Internet Quality</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>Access to Internet: Status</caption>
                    <td>FALSE</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>
                    <th>Computer Labs</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>Access to a Computer Labs</caption>
                    <td>FALSE</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>
                    <th>Science Labs</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>Access to a Science Lab</caption>
                    <td>FALSE</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>
                    <th>Rating--On-Time: [1: Low - 10: Very High]</th>
                    <th>Rating--Off-Time: [1: Low - 10: Very High]</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <caption>Access to Electricity</caption>
                    <td>Rating: 20&frasl;100</td>
                    <td>20 &percnt; availability </td>
                </tr>
                </tbody>
            </table>


        </td>
    </tr>

</body>
</html>
2
  • You mean <br/> tags are added?
    – gdarko
    Commented Jun 1, 2019 at 21:12
  • yes, exactly, a lot of them and they are making my code to have excessive space.
    – Tope Leye
    Commented Jun 1, 2019 at 22:08

1 Answer 1

0

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>
3
  • Pls where do I insert the jquery in the html?
    – Tope Leye
    Commented Jun 2, 2019 at 6:00
  • If you go with PHP one insert it in functions.php, the second one will probably go in footer before </body> tag.
    – gdarko
    Commented Jun 2, 2019 at 7:45
  • I added the script code before the </tbody>. It didn't change anything. Can I just add it anywhere in the functions.php file
    – Tope Leye
    Commented Jun 5, 2019 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.