Skip to content

Add color and size tag support#27

Open
Dahie wants to merge 4 commits into
jarrett:masterfrom
Dahie:add-color-tag
Open

Add color and size tag support#27
Dahie wants to merge 4 commits into
jarrett:masterfrom
Dahie:add-color-tag

Conversation

@Dahie

@Dahie Dahie commented Jun 22, 2020

Copy link
Copy Markdown

This is relating to #26

I opted to only have the options for :span and :remove for now. I'm not entirely happy about the use of global option, but I didn't want to rebuild the whole configuration management.

@jarrett

jarrett commented Jun 22, 2020

Copy link
Copy Markdown
Owner

Thanks! Would it be better if, in addition to the global config, we were to allow config overrides when #convert is called? I'd be happy to add that.

@Dahie

Dahie commented Jun 22, 2020

Copy link
Copy Markdown
Author

That wouldn't actually solve my design issue: Since the Grammar parser is abstracted away with Parslet and we only define the Nodes the parser is using, I don't know how to pass data from RbbCode#convert to the node instances. This is where my global config comes in at 9b3dda5#diff-3c56d0b32c0d74f930a5a545082ee319R200

@jarrett

jarrett commented Jun 22, 2020

Copy link
Copy Markdown
Owner

I can pass the config options through. Would you like to be able to do the following?

RbbCode.new.convert('This` is [b]BBCode[/b]', output_format: :markdown, :unsupported_features: :span)

@Dahie

Dahie commented Jun 23, 2020

Copy link
Copy Markdown
Author

I can pass the config options through.

Do you have an example?

The more I think about it, the more I want to avoid @@options. if we have to keep the @@options in RbbCode, the options are stored on class-level and all instances of RbbCode will access the same options hash. This may cause unintended effects and will be hard to debug for users.

Would you like to be able to do the following?

RbbCode.new.convert('This` is [b]BBCode[/b]', output_format: :markdown, :unsupported_features: :span)

Hm, I don't see how this would solve the @@options issue. Personally I don't see a gain in this right now. on the contrary, it'd break backwards-compatibilty for nothing. :/

@jarrett

jarrett commented Jun 23, 2020

Copy link
Copy Markdown
Owner

Example usage would be:

RbbCode.new.convert('This` is [b]BBCode[/b]', output_format: :markdown, :unsupported_features: :span)

So the question is whether you'd like to be able to call the API this way. That is, passing options on a per-convert basis, instead of only once upon instantiating RbbCode. I personally think it could be beneficial.

The class variable @@options doesn't currently exist, and I'm not planning on adding it. So I think we're in agreement on that. Or are you referring to the instance variable @options?

Comment thread lib/rbbcode.rb Outdated

def initialize(options = {})
@options = {
@@options = {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am introducing @@options here as a class variable in order to be able to use it in a static RbbCode.options called in the new Node classes. These don't have any reference to the RbbCode instance and I don't know how to inject options into them.

@Dahie

Dahie commented Jun 24, 2020

Copy link
Copy Markdown
Author
RbbCode.new.convert('This` is [b]BBCode[/b]', output_format: :markdown, :unsupported_features: :span)

You can introduce it. Personally I'm don't need it and if it replaces the options via initializer everyone using the gem would have to change. So I'll not integrate here. :)

@jarrett

jarrett commented Jun 24, 2020 via email

Copy link
Copy Markdown
Owner

@jarrett

jarrett commented Jun 24, 2020

Copy link
Copy Markdown
Owner

I updated the API on the master branch. As you'll see, this adds per-convert option overrides without breaking backwards compatibility. No class variable needed.

@Dahie

Dahie commented Jun 25, 2020

Copy link
Copy Markdown
Author

Alright, I changed my branch to incorporate that. @@options is not removed.

@jarrett

jarrett commented Jun 25, 2020 via email

Copy link
Copy Markdown
Owner

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

Successfully merging this pull request may close these issues.

2 participants