Setting word hyphenation on specific columns of a table

This forum is for all Flare issues not related to any of the other categories.
Post Reply
bwofficer
Propeller Head
Posts: 57
Joined: Tue May 12, 2020 2:16 am

Setting word hyphenation on specific columns of a table

Post by bwofficer »

I don't like having words automatically break and hyphenate at the end of lines. I have therefore turned hyphenation off (mc-hyphenate: never) in my p style.

The problem is that I have a few instances of tables with narrow columns where I do want to accept last-word-of-line hyphenation. If I don't, I'd end up with some very short lines in the narrow cells and the number of lines in those cells would grow too much.

I don't want to have last-word-of-line hyphenation turned on for all tables - just those with some narrow columns, and ideally only for those specific columns which are narrow.

What are my options? I'm still getting to grips with Flare, especially when it comes to tables. I don't have a websites or coding background, so styles and CSS don't come naturally to me. I'm learning, but I'm still at the "a little knowledge is a dangerous thing" stage.

Note that this is primarily for a PDF target intended for printing. Even if I later add an html output it'll be for viewing full screen on a PC built into an industrial machine, so I don't need to consider different screen sizes or responsive design or anything like that (thank goodness!).

I could create a style class p.tablePara in my stylesheet, with hyphenation turned on for that style, and specify in the table style creator that this style be used for all cells in the table.

But wouldn't that get overridden if I then apply a style to a particular para within a particular table instance, say to style it as a safety warning? A para can't be both p.tablePara and p.warningRED can it? (I'm asking this as a question because I'm right at the limit of my understanding of CSS here and I'm not at all sure if I'm right.) Also I'd need separate table styles for each hyphenation variant, wouldn't I? Wouldn't this double the number of table styles I need to create and maintain?

Alternatively I could create a selector td p in my stylesheet, to turn hyphenation on for paras inside a table. That would apply to all the paras inside the table even if some had been made p.warningRED wouldn't it? (Again, this is an honest question - I don't understand CSS all that well.) Also, if I created a td p rule in the stylesheet it would apply to ALL columns of ALL tables, and I don't really want that. I only want it to apply to tables with narrow columns.

I've found that I can select a cell in a table, or a range of cells like a column, open cell properties, and set local hyphenation rules for just those cells. However those are getting overridden by my main p style in the stylesheet having hyphenation turned off. I assume that's because the p is inside the td so the p properties are taking priority?

Either there's no ideal solution which gives me everything I want (possible) or there is but I'm just too inexperienced with CSS and with Flare to see what it is (very possible!). What do you folk out there do to control hyphenation of paras inside and outside of tables different, in a flexible but simple way?


Regards,

Bruce
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Setting word hyphenation on specific columns of a table

Post by ChoccieMuffin »

Lots of questions, I'll answer the one I can.
bwofficer wrote:I could create a style class p.tablePara in my stylesheet, with hyphenation turned on for that style, and specify in the table style creator that this style be used for all cells in the table.

But wouldn't that get overridden if I then apply a style to a particular para within a particular table instance, say to style it as a safety warning? A para can't be both p.tablePara and p.warningRED can it? (I'm asking this as a question because I'm right at the limit of my understanding of CSS here and I'm not at all sure if I'm right.)
If you want to go down that route, I'd instead create a GENERIC style (.Hyphens-On) and apply that to assorted paragraphs where you want the text to hyphenate. If that paragraph already HAS a style applied, e.g. p.WARNING, in the Text Editor you CAN have more than one style applied. The Text Editor contains <p class="WARNING">. Edit this to "<p class="WARNING Hyphens-On">".That way Flare applies the WARNING attributes and then the Hyphens-On attributes. Fiddly, but it works.

I don't think just manually applying your .Hyphen-On generic style to a table column would work, because of the cascading nature of stylesheets. You'd be turning on hyphenation to the column, but any <p> inside the column would then turn hyphenation off.

In your TableStyle editor you CAN apply your .Hyphens-On class to paragraphs in a specific column. Select the Columns tab, then select the narrow column, scroll down to the Cell Content Style group at the very bottom and in the Tag box select p and in the Class box select .Hyphens-On.

Hope that helps.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
doloremipsum
Sr. Propeller Head
Posts: 290
Joined: Mon Aug 26, 2019 2:11 pm

Re: Setting word hyphenation on specific columns of a table

Post by doloremipsum »

ChoccieMuffin's response is perfect for someone who is just learning CSS - I have another suggestion for when you're feeling more confident.
If your tables with narrow columns have a specific style class, you can specify that you want any paragraphs (of any type) within that table to use hyphens. You do this using the descendant advanced selector. The CSS would look like this:

Code: Select all

table.narrow p
{
    mc-hyphenate: auto
}
This essentially says: let all p's that are descendants of a narrow table use this style definition. This should override the standard setting you have on the generic p class.
(Sorry for doing this in code, I'm sure you can set this up in the normal stylesheet editor as well. I believe this should be in your normal stylesheet instead of your table stylesheet.)
in hoc foro dolorem ipsum amamus, consectimur, adipisci volumus.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Setting word hyphenation on specific columns of a table

Post by ChoccieMuffin »

doloremipsum wrote:ChoccieMuffin's response is perfect for someone who is just learning CSS - I have another suggestion for when you're feeling more confident.
If your tables with narrow columns have a specific style class, you can specify that you want any paragraphs (of any type) within that table to use hyphens. You do this using the descendant advanced selector. The CSS would look like this:

Code: Select all

table.narrow p
{
    mc-hyphenate: auto
}
This essentially says: let all p's that are descendants of a narrow table use this style definition. This should override the standard setting you have on the generic p class.
(Sorry for doing this in code, I'm sure you can set this up in the normal stylesheet editor as well. I believe this should be in your normal stylesheet instead of your table stylesheet.)
dolerumipsum, this is where I was trying to get to but couldn't remember how to! Thanks for building on my suggestion and reminding me what to do. Where I was falling down was trying to narrow down specific columns, but when you look in a table stylesheet there are tons of columns so I couldn't figure out how you'd know which column to pick, so approached it from a different direction. Of course your suggestion to allow hyphens for all columns in the entire table is great.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
bwofficer
Propeller Head
Posts: 57
Joined: Tue May 12, 2020 2:16 am

Re: Setting word hyphenation on specific columns of a table

Post by bwofficer »

Thank you, ChoccieMuffin. Lots of useful tips in there.
ChoccieMuffin wrote:If you want to go down that route, I'd instead create a GENERIC style (.Hyphens-On) and apply that to assorted paragraphs where you want the text to hyphenate. If that paragraph already HAS a style applied, e.g. p.WARNING, in the Text Editor you CAN have more than one style applied. The Text Editor contains <p class="WARNING">. Edit this to "<p class="WARNING Hyphens-On">".That way Flare applies the WARNING attributes and then the Hyphens-On attributes. Fiddly, but it works.
I didn't realise that you could apply two style classes like this. Useful to know, and not just for this particular problem.

I don't think just manually applying your .Hyphen-On generic style to a table column would work, because of the cascading nature of stylesheets. You'd be turning on hyphenation to the column, but any <p> inside the column would then turn hyphenation off.
ChoccieMuffin wrote:In your TableStyle editor you CAN apply your .Hyphens-On class to paragraphs in a specific column. Select the Columns tab, then select the narrow column, scroll down to the Cell Content Style group at the very bottom and in the Tag box select p and in the Class box select .Hyphens-On.
My first thought was that this wouldn't work because I'd need to be able to specify that columns 3 and 5 (for example) would always be the narrow ones for ALL tables that are created using this stylesheet. But on reconsideration that's not as much of a limitation as I it first appeared. There are some table layouts I'll be using time after time without modification, such as the diagnostic message table layout. For those I CAN say that certain columns will always be narrow ones.

Thanks, again.

Regards,

Bruce
bwofficer
Propeller Head
Posts: 57
Joined: Tue May 12, 2020 2:16 am

Re: Setting word hyphenation on specific columns of a table

Post by bwofficer »

doloremipsum wrote:If your tables with narrow columns have a specific style class, you can specify that you want any paragraphs (of any type) within that table to use hyphens. You do this using the descendant advanced selector. The CSS would look like this:

Code: Select all

table.narrow p
{
    mc-hyphenate: auto
}
This essentially says: let all p's that are descendants of a narrow table use this style definition. This should override the standard setting you have on the generic p class.
Sorry for doing this in code, I'm sure you can set this up in the normal stylesheet editor as well. I believe this should be in your normal stylesheet instead of your table stylesheet.)
Thanks. I'll give that a go. And don't worry about expressing it as CSS code - despite me being relatively inexperienced with Flare, CSS, and even web-oriented technologies in general, I'm finding that when it comes to stylesheets I much prefer viewing and editing them in the text editor even if it's a steeper learning curve. I prefer the control it gives me - the ability to micromanage the styles, to order them and group them as I see fit, to add comments wherever I want, etc.

Regards,

Bruce
doloremipsum
Sr. Propeller Head
Posts: 290
Joined: Mon Aug 26, 2019 2:11 pm

Re: Setting word hyphenation on specific columns of a table

Post by doloremipsum »

Hmm, on re-read my suggestion is best for the entire table, but probably can't be narrowed down to specific columns - they're not really proper items with descendants in the HTML. ChoccieMuffin's option might work better for this specific problem!
bwofficer wrote:And don't worry about expressing it as CSS code - despite me being relatively inexperienced with Flare, CSS, and even web-oriented technologies in general, I'm finding that when it comes to stylesheets I much prefer viewing and editing them in the text editor even if it's a steeper learning curve. I prefer the control it gives me - the ability to micromanage the styles, to order them and group them as I see fit, to add comments wherever I want, etc.
Totally agree, that's exactly how I felt when I was starting out! Much easier to use the text and google anything you're not sure about than struggle with the slow style editor :lol:
in hoc foro dolorem ipsum amamus, consectimur, adipisci volumus.
bwofficer
Propeller Head
Posts: 57
Joined: Tue May 12, 2020 2:16 am

Re: Setting word hyphenation on specific columns of a table

Post by bwofficer »

doloremipsum wrote:Hmm, on re-read my suggestion is best for the entire table, but probably can't be narrowed down to specific columns - they're not really proper items with descendants in the HTML.
I'm experimenting putting a rule like the one below into my regular stylesheet. Assuming that hyphenation has been turned off in my p style, this would turn it back only for the 2nd cell in each row of a table based on the diagnosticMsgTable table stylesheet.

Code: Select all

table.TableStyle-diagnosticMsgTable tr td:nth-child(2) p { mc-hyphenate: always; }
So long as I don't muck about merging cells, the 2nd column cells will always be the 2nd cells in their rows.

It seems to work OK.


Regards,

Bruce
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Setting word hyphenation on specific columns of a table

Post by ChoccieMuffin »

Well done, Bruce, happy to see you getting stuck in and playing in your stylesheet! :D

I have w3schools.com bookmarked, and you'll find some useful resources and information in there to do with CSS.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Post Reply