Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a setting to remove the display of line breaks on the boundaries of the bbcode and its content in HTML #937

Open
MioVisman opened this issue Apr 9, 2023 · 6 comments

Comments

@MioVisman
Copy link

Extra blank lines in HTML if bbcode is on a separate line from the content.
Example

[code]
abcde
12345
[/code]

result
i1

or

---
[b]
abcde
12345
[/b]
---

result
i2

Maybe I searched badly, but I did not find a method to solve the problem.
Made a crutch forkbb/forkbb@2e4941b

P.S.
After that, the text with bbcodes changes of course

---
[b]abcde
12345[/b]
---

But it's better than empty lines :|

@samclarke
Copy link
Owner

Do you want to add a line break after the opening tag and before the closing tag? If so, there is the breakStart and breakEnd BBCode options which do that. They would need to be added to each individual BBCode.

For example: https://jsbin.com/saqagiyife/edit?html,js,output (only the [b] and [code] tags have been updated in the example).

There is also a breakStartBlock and breakEndBlock options which will do the same but for all block BBCodes. Unfortunately, there isn't an option to do it for all BBCodes so inline BBCodes will still need to have breakStart / breakEnd added manually.

@MioVisman
Copy link
Author

I raised a situation where messages with bbcodes were created not by the editor, but manually. In this case, such newlines may occur.
On forum pages (eg fluxbb, punbb, forkbb) such messages are displayed without these extra empty lines, as the parsers swallow these newlines.
But if this message is opened for editing in sceditor, then it looks ugly, the name has many empty lines at the beginning and end of the bbcodes.
I corrected this situation for myself with a crutch (link above). But maybe someone else with a similar situation will face / faced.

@samclarke
Copy link
Owner

Are you wanting to ignore the first/last line of BBCodes like breakStart/breakEnd does without the editor outputting them?

Or is it that all first/last newlines at the start/end of BBCodes should be ignored? So a BBCode like:

---
[b]

test

[/b]
---

would be the equivalent of:

---
[b]test[/b]
---

@MioVisman
Copy link
Author

MioVisman commented Apr 10, 2023

Are you wanting to ignore the first/last line of BBCodes like breakStart/breakEnd does without the editor outputting them?

Yes.

My code removes 1 empty line at the beginning and 1 empty line at the end if they are present in the content. For all bbcodes.
content = content.replace(/^\x20*<br \/>/, '').replace(/<br \/>\x20*$/, '');

@samclarke
Copy link
Owner

Is there a reason for not wanting the lines added to the output when they're supported in the input?

If they're not added to the output, what should happen when editing previously output BBCode or if toggling between WYSIWYG and BBCode? As that will cause lines to be removed.

For example, with the BBCode:

[code]

Should have a single line above.
[/code]

The first time it's edited there will be one line above but if the ignored lines aren't added to the output, the resulting BBCode will be:

[code]
Should have a single line above.[/code]

Then, the next time it is edited/toggled between source and WYSIWYG, the line above will be stripped.

@MioVisman
Copy link
Author

Yes, but do leading and trailing lines within bbcodes make sense?
Can it be correct to place empty lines outside of bbcodes?
I don't know, I need more experience with messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants