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

Remove hardcoded bold font for first line in abstract #379

Merged
merged 2 commits into from
Dec 23, 2015

Conversation

nawroth
Copy link
Contributor

@nawroth nawroth commented Dec 21, 2015

The feature could be re-introduced with theming support later on.
As it stands before this change, it limits the styling of abstract blocks too much.

Fixes #378.

@mojavelinux
Copy link
Member

There are users that depend on this feature, so we can't remove it outright. The theme setting will need to be part of this change. I would prefer for the default theme to define the bold style for the first line as that is part of the design of the default theme, but I 100% agree it should be possible to control it.

@nawroth nawroth force-pushed the fix-abstract-font-styling branch 2 times, most recently from 9fb26da to 294b452 Compare December 22, 2015 21:51
@nawroth
Copy link
Contributor Author

nawroth commented Dec 22, 2015

@mojavelinux I wasn't sure about the naming but went with abstract_firstline_font_style.
It didn't make sense for me to have first in the hierarchy.
Unless we want to have first_line and first_character in the future ... or something!

@mojavelinux
Copy link
Member

That's close to the name I had in mind. How about first_line instead of firstline to be more consistent with CSS.

abstract:
  first_line_font_style: bold

We don't need it in the base theme, just the default theme. Since it could be absent, can you write it as the following?

prose_opts = { line_height: @theme.abstract_line_height }
if (first_line_font_style = @theme.abstract_first_line_font_style) && first_line_font_style != font_style
  prose_opts[:first_line_options] = { styles: [font_style, first_line_font_style] }
end

It didn't make sense for me to have first in the hierarchy.

It doesn't matter. That's just a coding styling. All the levels are flattened using an underscore. I tend to keep it flat until there are at least two keys.

To summarize:

  • remove from base theme
  • rename to first_line
  • only pass :first_line_options if key is set in theme

Then we'll be good to merge!

@mojavelinux
Copy link
Member

Unless we want to have first_line and first_character in the future ... or something!

That's definitely the long-term plan. As much of core CSS that we can replicate, the easier it is on the designer. But we'll take it a chunk at a time.

@nawroth nawroth force-pushed the fix-abstract-font-styling branch 2 times, most recently from cf61a2e to d510cc7 Compare December 22, 2015 23:02
@nawroth
Copy link
Contributor Author

nawroth commented Dec 22, 2015

@mojavelinux Pushed. Your code snippet is missing a to_sym !

More than extra options for the first line, I'd like to see borders supported for abstract blocks. Maybe it's just a bug around that?

prose_opts = { line_height: @theme.abstract_line_height, first_line_options: { styles: [font_style, :bold] } }
prose_opts = { line_height: @theme.abstract_line_height }
# FIXME control more first_line_options using theme
if (first_line_font_style = @theme.abstract_first_line_font_style.to_sym) && first_line_font_style != font_style
Copy link
Member

Choose a reason for hiding this comment

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

Using .to_sym in the assignment will throw an exception if this key is not present. Therefore, the .to_sym need to be moved to where first_line_font_style is referenced once the truthy check passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not having any idea how expensive to_map is, I'll go with a nested if.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

The general rule of thumb with Ruby is to avoid method calls if there's another way to do it without one. So the nested if is the right choice in this case (or just call .to_sym both times)!

@mojavelinux
Copy link
Member

We have support for putting borders around blocks but, like with all things in Prawn, we have to explicitly add the logic. Borders are a bit tricky though because they can span pages, so the abstraction is still a bit weak atm. Similar to #342, but no dedicated issue exists.

@mojavelinux
Copy link
Member

Thanks!

mojavelinux added a commit that referenced this pull request Dec 23, 2015
resolves #378 Remove hardcoded bold font for first line in abstract
@mojavelinux mojavelinux merged commit adeb26c into asciidoctor:master Dec 23, 2015
@nawroth nawroth deleted the fix-abstract-font-styling branch December 23, 2015 07:48
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