从WordPress的单元格内容中删除换行符

时间:2019-06-01 作者:Tope Leye

表格单元格中的换行符转换为⟨br⁄⟩ 保存时。我必须删除单元格内容中的所有换行符,否则段落、列表项等之间会有过多的空间。这会使一大块内容比应该编辑的内容更难编辑,因为它们都是拼凑在一起的。

是否有防止任意插入的选项或解决方法⟨br⁄⟩’单元格内容中的?或者有没有办法将表中的换行符转换为false

我也希望通过破解代码来减少代码并提高效率。

我在WordPress中寻找在线插件来选择和删除所有HTML文件,但我找不到它们。

<!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>

1 个回复
SO网友:gdarko

这个<br/> 标记由连接到\\u内容过滤器的wpautop函数添加。因此,您需要将其从显示表的页面中取消挂钩。有几种方法可以做到这一点。

使用PHP,您可以这样做(将“your\\u page/post\\u id”更改为实际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 );
使用jQuery,您可以执行以下操作:

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