The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    New line in post add br

    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved New line in post add br

    Post by LeChat September 26th 2023, 2:34 pm

    Technical Details


    Forum version : #phpBB3
    Position : Founder
    Concerned browser(s) : Mozilla Firefox, Google Chrome, Opera, Safari
    Screenshot of problem : https://i.imgur.com/b34ES6z.png
    Who the problem concerns : All members
    Forum link : https://cadikim.forumpl.net/t11-wzor-telefonu#48

    Description of problem

    The enters used in the post add
    Code:
    <br>
    tags to the HTML, which spoils the appearance of the code (see screenshot). However, I would like to keep these "enters" for better visibility and editability of the code for users.

    Is there a way to fix this so that the enters do not add
    Code:
     <br>
    ?


    Last edited by LeChat on September 26th 2023, 5:50 pm; edited 2 times in total (Reason for editing : Last title was confusing)
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1581
    Reputation : 268
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: New line in post add br

    Post by Razor12345 September 26th 2023, 2:59 pm

    Good evening!

    It is better not to use the br tag.
    This has certain downsides to the responsiveness of the style on different devices
    Add a better
    Code:
    margin
    property to the
    Code:
    .tele_bg p
    instruction

    Result:

    New line in post add br Scree363



    New line in post add br Screen51
    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved Re: New line in post add br

    Post by LeChat September 26th 2023, 3:35 pm

    The problem is, I do not use it. When I published my code, every new line in my editor add a <br>. It looks like this in editor:

    New line in post add br URtf9pk

    The code is correct when I dont use new line in editor, but it isn't good for my users - which will be editing this code.

    New line in post add br RHGfG5S
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1581
    Reputation : 268
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: New line in post add br

    Post by Razor12345 September 26th 2023, 4:23 pm

    Unfortunately, this is how the HTML code in the post is interpreted.
    Try AP - Modules - Javascript codes management - Create a new Javascript

    Title: any
    Placement: In the topics
    Javascript Code:
    Code:
    $(document).ready(function() {
      document.querySelectorAll('.postbody').forEach((item) => {
        item.querySelectorAll('br').remove();
      });
    });

    Result:
    Before:

    New line in post add br Scree365

    After:

    New line in post add br Scree367



    New line in post add br Screen51
    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved Re: New line in post add br

    Post by LeChat September 26th 2023, 4:49 pm

    I don't have
    Code:
    .postbody
    on my forum. I tried to replaced it with
    Code:
    .tele_bg
    to assign it only to this code, not entire forum, but it doesn't work. I'll try to rebuilt the code, maybe in flex, to solve this issue.

    Request isn't solved, but I think we can move it to garbage.

    Thanks for your help anyway. Smile
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1581
    Reputation : 268
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: New line in post add br

    Post by Razor12345 September 26th 2023, 5:15 pm

    Since you keep two code display options, the br tags don't appear in the first one.
    Because the code can't find the br tags in the first code, it breaks.
    You need to add a check. Here is the updated code:

    Code:
    $(document).ready(function() {
      const specialElement = document.querySelectorAll('.tele_bg')
      if (specialElement) {
      specialElement.forEach((item) => {
          const br = item.querySelectorAll('br');
            if (br) {
              br.forEach((item) => {
                item.remove();
              });
            }
      });
    }
    });

    Result:

    New line in post add br Scree368

    If your request is resolved or you wish to end the discussion, mark the topic as solved.



    New line in post add br Screen51

    sivastar likes this post

    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved Re: New line in post add br

    Post by LeChat September 26th 2023, 5:50 pm

    Razor12345, thank you very much for your help! However, I realized that I was an idiot because instead of a script, I simply added this line to the code.
    Code:
     .tele_bg br {display: none}
    and everything works wonderfully.

    I marked topic as solved.
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1581
    Reputation : 268
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: New line in post add br

    Post by Razor12345 September 26th 2023, 6:48 pm

    You are welcome!

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules



    New line in post add br Screen51

      Current date/time is November 11th 2024, 8:24 pm