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

Unclosed "tag" treated as tag #36

Open
ifly6 opened this issue Jun 24, 2022 · 2 comments
Open

Unclosed "tag" treated as tag #36

ifly6 opened this issue Jun 24, 2022 · 2 comments

Comments

@ifly6
Copy link

ifly6 commented Jun 24, 2022

Given input like:

>>> import bbcode
>>> bbcode.render_html('He said "[I]n the matter of X v Y, X wins".')
'He said &quot;<em>n the matter of X v Y, X wins&quot;.</em>'

Is it possible to have the mis-identified tag – or tags in general – not close except when there is a matching closing tag, eg [/i]? (Such behaviour is default in phpBB, for example).

Thanks for any help.

@dcwatson
Copy link
Owner

dcwatson commented Jul 8, 2022

If I understand what you're asking for, this isn't currently possible, but it's a good idea. I think it mostly belongs as a tag option (require_close), but also maybe have a Parser.strict mode switch to set require_close on any installed tag that doesn't explicitly set the option. Obviously some tags (standalone and same_tag_closes; i.e. [hr] and [*]) should not ever require closing tags, even in strict mode.

At first glance, I think it will require changing _find_closing_token to return whether a closing token was actually found or not. Then _format_tokens can act accordingly.

I'll have a look, but can't promise any specific timeline.

@ifly6
Copy link
Author

ifly6 commented Aug 4, 2022

Thanks for taking a look. If I get some time (some IRL stuff has intervened) I'll perhaps take a look myself. Though I think the thing to do would instead be to merely pass the "tag" on unchanged rather than something like require_close? Unless I am misunderstanding your comment.

@dcwatson dcwatson assigned dcwatson and unassigned dcwatson Sep 14, 2022
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