Table accepts character formatting, then ignores

This forum is for all Flare issues not related to any of the other categories.
Post Reply
kevinmcl
Sr. Propeller Head
Posts: 252
Joined: Mon Sep 11, 2006 10:58 am

Table accepts character formatting, then ignores

Post by kevinmcl »

I have a table style that I apply when I want to format text in a certain way - basically, a table with no visible outlines, which allows me to format content in columns.

Sometimes, that content should be the output of a shell command-line command, where I want the text to be mono-spaced to simulate the command-line look.

So, I click and drag from first cell (upper left) to last cell (lower right), and apply ".code" character style.
Just like magic, the table looks like the output from a CLI command.

Then I save the topic and close it.

When I reopen the topic, the table retains the selected table style attributes, but the applied character style is nowhere to be found.

My question then: If Flare is going to wipe out the character style, why does it let me apply it and SHOW that it's applied?

My follow-up questions are: Am I the only person who has the problem?
If I'm not, then what is the purpose of that "functionality"?
De gustibus non disputandum est
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Table accepts character formatting, then ignores

Post by LTinker68 »

Normally, when you apply an inline style, it will override the stylesheet referenced at the top of the topic. However, table stylesheets are a bit different, because the styles are reapplied (redrawn, if you will) when you modify the table (add/delete a row or column) and when you open a topic. That is, the table, tr, th, td, and other table structure elements are redrawn -- the content inside the table cell tags (th, td) aren't affected. When you apply the inline style as you describe, you're adding a style attribute to the td tag, and when that tag is redrawn, it's done so without the style attribute, so the inline style is lost.

To get around that, you need to put that content in the cell inside a paragraph and then apply the inline style to the paragraph tag (or better yet, create a paragraph class in the main topic stylesheet and apply the class to that paragraph). When the table is redrawn, the paragraph remains as is, since the paragraph tag isn't part of the table structure itself.

Hope that helps.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
kevinmcl
Sr. Propeller Head
Posts: 252
Joined: Mon Sep 11, 2006 10:58 am

Re: Table accepts character formatting, then ignores

Post by kevinmcl »

Well... it does and it doesn't. Thanks.

Lacking a better way to do it (suggestions?) I'm using tables to format simulated command-line output.

For verisimilitude, it needs to be in monospaced font. All other contents of all other tables are in my normal corporate proportionally-spaced font for general text'n'stuff (so I probably shouldn't set table text style to the mono font).

I've been doing what you suggest, hoping there was a better way. A less time-consuming way. I must have a hundred tables to convert (each with anywhere from 3 to 100 rows, and multiple columns), and more to create all the time. That's thousands and thousands of individual cells to select contents and apply ".code" character style (or whatever). I also have to individually add a couple of non-breaking spaces following the text in each cell, so that it can be easily selected without accidentally selecting the cell structure (which seems a nearly impossible distinction, for my mouse, anyway, when the desired text fills the cell, with no "buffer" spaces).

At least for the moment, your reply tells me that I'm doing the font thing the way I have to.

But IS there a better way to format command-line output to look a bit like the real thing?
See attached .PNG for just one example.
... and ooops! I just spotted a copy'n'paste error in that table.
You do not have the required permissions to view the files attached to this post.
De gustibus non disputandum est
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Table accepts character formatting, then ignores

Post by LTinker68 »

kevinmcl wrote:I've been doing what you suggest, hoping there was a better way. A less time-consuming way. I must have a hundred tables to convert (each with anywhere from 3 to 100 rows, and multiple columns), and more to create all the time.
When I read the original post, I was under the impression that only a few cells in the table would be the mono-space font and the rest of the table would be the normal font. If all the cells are mono-space font, then just copy the original table stylesheet, give the copy a new name, and set its font to the mono-space font. Then you just swap the table stylesheet associated with the table in a topic depending on which font you want used. You would have to go topic-by-topic to do the switch, though.

You could also try a complex selector in the main topic stylesheet that would change the font of the paragraph class used in the table depending on if the table had a specific ID (name) associated with it. However, I haven't tried complex selectors with table stylesheets (I don't generally use table stylesheets) and I don't have Flare running at the moment so I can't confirm if the table stylesheet reference at the top of the topic is listed after the main topic stylesheet or before it. If the table stylesheet reference comes after the topic stylesheet, then a complex selector in the main topic stylesheet should work. If the topic stylesheet reference is first, though, then you'd have to try the complex selector in the table stylesheet. I've also never tried that, so I don't know if Flare will leave that complex selector in the table stylesheet alone or if it will blow it out when it redraws the tables. If you can use the complex selector in either case, then you'd just name the table in the topics where you want the paragraph class to use a mono-space font instead of the standard font.

BTW, you might want to consider snippets for when you create the tables from now on (i.e., in new topics), especially if you end up using complex selectors with a table name. You create two snippets, one with the name, one without, or one with no paragraphs and paragraph classes in it and one with the paragraph classes. Then you insert whichever snippet is appropriate to a topic and break the link to the snippet to make it editable in the topic. So the snippets in this case are sort of formatting templates you use to get you started, but aren't intended to be used as a single-source block of text.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
kevinmcl
Sr. Propeller Head
Posts: 252
Joined: Mon Sep 11, 2006 10:58 am

Re: Table accepts character formatting, then ignores

Post by kevinmcl »

Now that thing with the snippets is a neat idea.

I'll look further in the uses and abuses of complex selectors, too.
De gustibus non disputandum est
crdmerge
Sr. Propeller Head
Posts: 248
Joined: Tue Dec 16, 2008 5:37 am

Re: Table accepts character formatting, then ignores

Post by crdmerge »

Couldn't you surround all of your mono-space content with the <pre></pre> tag set? From the W3schools site (http://www.w3schools.com/html/html_formatting.asp):
The <pre> tag defines preformatted text.
Text in a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks.
With this formatting, tables would be unnecessary.


Good luck,
Leon
kevinmcl
Sr. Propeller Head
Posts: 252
Joined: Mon Sep 11, 2006 10:58 am

Re: Table accepts character formatting, then ignores

Post by kevinmcl »

I was doing that for a while, but found it stirred up a lot of odd problems, especially when I want to insert comments to users among the "CLI" elements.
De gustibus non disputandum est
wilma
Propeller Head
Posts: 15
Joined: Sat Jul 16, 2011 11:36 am
Contact:

Re: Table accepts character formatting, then ignores

Post by wilma »

Yes it happens to me, too. We are documenting software applications so, as Microsoft writing rules state we have to put in bold every reference to the application GUI. So we write in tables the procedures steps and we use the inline bold formatting. unfortunately if the paragraph is not in a 'p' but is in a "td" the inline formatted text appears different.
See below:
Image
Vilma Zamboli
http://www.writec.com
Image
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Table accepts character formatting, then ignores

Post by LTinker68 »

That's weird and not something that would normally happen. The first thing that comes to mind is that perhaps there's a a stylesheet definition that's in effect, such as a complex selector that says if a bold tag is inside a td tag, then set its line-height to x or make it superscript (not likely) or set its vertical-align to top or some other attribute that's forcing the text up relative to the rest of the paragraph. Do you have the same problem when you use the inline bold tag on a regular paragraph outside the table? If not, then it would definitely point to a complex selector in the stylesheet.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Post Reply