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

Expand classes #4

Closed
dreaming-augustin opened this issue Mar 9, 2017 · 3 comments
Closed

Expand classes #4

dreaming-augustin opened this issue Mar 9, 2017 · 3 comments

Comments

@dreaming-augustin
Copy link

Thanks for this little converter. It's simple and does the job.

It'd be nice to have a programmable support for HTML classes.
Suppose I have HTML which includes classes:
<strong class="notice">Important information</strong>
We could have a framework where we could program instances of classes, and how to render them in BBCode.
For example, class="notice" could be wrapped in red colour:
[b][color=#FF0000]Important information[/color][/b]

The library could thus be made class aware. The user could register a class and tell the library how to render it. When the converter finds a class, it looks up if it is among registered classes, and handles it appropriately.

@dreaming-augustin
Copy link
Author

It should also work for tags that are currently stripped, like <p> or <span>.

<span class="notice">Important information</span>
would become:
[color=#FF0000]Important information[/color]

@dreaming-augustin
Copy link
Author

The major hurdle I see is that the converter does not seem to be aware of pairs of tag, so it wouldn't know where to add the closing bbcode tag for the HTML element with a given class.

Implementing what I propose would require the converter to be DOM aware. I am aware that it would require a major refactor of the current code.... :-/

@dedalozzo
Copy link
Owner

Hi,

I have written this library to convert over 20.000 articles originally written using HTML and BBCode and I'm aware that HTML parsing shouldn't be done using regex, but I didn't want to write a parser from scratch and the articles I had to convert are not HTML document, they are just text files using some HTML tags. And yep, the library did the job.

To achieve the goals you have in mind the library should use the pattern Command and maybe implement the Decorator pattern as well. It's not a big work to refactor it, but sincerely I don't have time, neither I'm interested to do that. I have too much things going on. But feel free to fork the project.

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