Can I apply table styles as pre- or post-build event?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Can I apply table styles as pre- or post-build event?

Post by ChoccieMuffin »

Long and painful story short, I have a ton of Word docs that get imported using scripts. I don't ever touch them in Flare but use build scripts to import the Word docs into a whole bunch of Flare projects and then generate PDF targets.

Is it possible to apply table styles to tables without doing so either from the settings in the import file or from within the Flare GUI? For reasons I won't go into (mainly to do with how table headers are dealt with in the source documents) applying the table style from the import isn't enough for me.

What I'm thinking of is the equivalent of this procedure in the Flare GUI:
1. Open the table stylesheet.
2. On the local toolbar, click Apply Style, select all HTM files, overwrite existing table styles and remove local formatting.

If it helps, there is the possibility of doing some kind of search-and-replace in the imported HTM files before building, but that would need to be a change I could apply to any table, regardless of the content of the header row.

The help on this is only one topic and doesn't go into detail, and doesn't mention doing any Flare-specific things, so I fear it's not possible but thought I'd ask in case any of you clever people might have an answer I'll like.
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
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Can I apply table styles as pre- or post-build event?

Post by NorthEast »

It might be possible using find and replace:

1. Open Find and Replace, Find Elements tab.
2. Choose how to Find your table - e.g. you might find Tag - table to select all tables, or find Class - <class name> to only find tables of a particular class.
3. Set Replace/Action to Set Attribute => style => mc-table-style: url('Resources/TableStyles/YourTable.css');

So this will change <table> to <table style="mc-table-style: url('Resources/TableStyles/YourTable.css');">

When you build the project, Flare appears to add in all the extra table stuff required - it adds the CSS link in the head, and adds classes to all the table tags.
(Flare will also automatically add this stuff if you open the source topic in the editor, but it looks like it isn't actually required in the source, since the build process adds it.)

So it looks like it might work, but I'd suggest you do some proper testing.

The tricky part is the path to the stylesheet is relative to the topic. That means if your topics are inside nested folders, then you need to use a separate find/replace for topics in each folder.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Can I apply table styles as pre- or post-build event?

Post by ChoccieMuffin »

Dave, you are a total star! I'll do a ton of testing and will let you know if it works.

Given the way my projects are structured the stylesheet is always going to be in the same relative location, so I think I might have a solution. Though it won't involve using the Flare GUI Search and Replace, as I do my assorted tidying up searches outside of Flare completely on the imported HTML files. And now I'd better go, I have lots of testing to do...
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
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Can I apply table styles as pre- or post-build event?

Post by NorthEast »

ChoccieMuffin wrote:Dave, you are a total star! I'll do a ton of testing and will let you know if it works.

Given the way my projects are structured the stylesheet is always going to be in the same relative location, so I think I might have a solution. Though it won't involve using the Flare GUI Search and Replace, as I do my assorted tidying up searches outside of Flare completely on the imported HTML files. And now I'd better go, I have lots of testing to do...
Well, that example is using the Flare find and replace GUI, but there's no reason why you couldn't use an external find/replace tool to update the topic files in some sort of a batch process. If you can add that attribute (style="mc-table-style:...") to the table tag, then it should work - fingers crossed.
For example, I use FAR HTML (which is now free), which would easily handle that sort of thing.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Can I apply table styles as pre- or post-build event?

Post by ChoccieMuffin »

Yep, FAR HTML is my go-to for that kind of thing. Banging my head on other problems with my process so haven't been able to verify this just yet, but I'm hopeful. :)
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