• Resolved spinhead

    (@spinhead)


    I make extensive use of code tags on my personal site. wpautop adds br tags to each line, somehow doubling the line space.

    If I change the code tags to pre tags, all is well. However, over the years I’ve developed the habit of using the code button at the top of the editor, and I don’t want to change my workflow, I want to make the tool behave as I’d like, if possible.

    I’m in unfamiliar waters. Is there a way to cause wpautop to stay out of code tags, as it already does with pre tags?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • threadi

    (@threadi)

    wpautop has a 2nd parameter that can be used to activate or deactivate the insertion of line breaks. See: https://developer.www.ads-software.com/reference/functions/wpautop/

    Whether and how this helps in your case is difficult to judge without knowing your code. But try it first.

    Thread Starter spinhead

    (@spinhead)

    I don’t understand the relevance of your comment.

    I am not invoking wpautop manually. It is running as part of the WP core.

    I am not using any custom code, I am simply putting text into the Classic Editor and surrounding it with <code> tags.

    Turning off line breaks in wpautop is universal. I do not want that. As stated in my question, I only want to turn off automated line breaks *inside* <code> tags in some automated way which won’t affect the hundreds of existing posts.

    threadi

    (@threadi)

    Now I understand your concern better. Based on your previous question with the many references to the code itself, I assumed that you had your own implementation.

    As you can see in the documentation https://developer.www.ads-software.com/reference/functions/wpautop/, there are no options in wpautop to further customize the output. There is also no hook there that could be used to influence this. I would therefore recommend that you give your request to the developers in Core Trac so that they can take this into account in a future version: https://core.trac.www.ads-software.com/newticket (perhaps code should be handled in a similar way to pre, which is currently implemented in the function).

    Thread Starter spinhead

    (@spinhead)

    surely there is some way to write a function which would tell wpautop to ignore the text between the code tags as it does with pre tags. or to remove inserted breaks at render time. I’m just struggling to envision it. due to cognitive damage from covid I’ve written very little code the past 5 years so I’m rusty but I’m using projects like this as part of my therapy.

    Thread Starter spinhead

    (@spinhead)

    css to hide all br that are children of code

    code br {display:none;}
    seems viable. am I missing something obvious?

    Thread Starter spinhead

    (@spinhead)

    bingo. solved.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.