Is there a way to apply Paragraph styles on a conditional basis
I think the question I am asking is the following:
Is there a way to apply Paragraph styles on a conditional basis (until they encounter a specific character or word) or, if that is not possible, is it possible to create line breaks after character styles?
This is the problem I am trying to solve:
I am using InDesign's Data Merge functionality. I have data that I would like to format as lists. If possible I would like to combine data from multiple cells in one text frame, that gets formatted with nested styles. I would like each list element to have a bullet point, that I would prefer not to add to the csv file. The number of items in each list fluctuates, but I am fairly confident I can predict an upper limit. I would like to refrain from manual search and replace manipulation on the merged document.
I have tried four approaches.
The first approach was to insert each cell into a new line, and format the text cell with paragraph styles. What works well is the fact that extra empty lines are automatically removed when using
Remove Blank Lines for Empty Fields. My problem with this approach is that the number of list elements is not fixed, so I don't think I can use the
Next Style option in the paragraph style menu.
List one:Â¶ <<data_a1>>Â¶ <<data_a2>>Â¶ <<data_a3>>Â¶ List two:Â¶ <<data_b1>>Â¶ <<data_b2>>Â¶ <<data_b3>>Â¶
(regular line breaks are denoted by
My second approach was to create data fields in the csv file for the maximum amount of list items possible, adding them to the the text frame, and separating them with forced line breaks. I can then apply a paragraph style that has nested styles for the first line and the data fields. With this approach I end up without bullet point for the list items, since they are separated by forced line breaks and not paragraphs, and I end up with extra forced line breaks even when I turn on
Remove Blank Lines for Empty Fields in the Data Merge options panel. Here is what this looks like in InDesign. The two lists have a
list paragraph style applied, that has nested styles for the first line until it encounters a forced line break and a style for the list items
List one:Â¬ <<data_a1>>Â¬ <<data_a2>>Â¬ <<data_a3>>Â¶ List two:Â¬ <<data_b1>>Â¬ <<data_b2>>Â¬ <<data_b3>>Â¶
(forced line breaks are symbolized by
Â¬, paragraphs by
My third approach was to combine all list elements in one cell inside the csv file, separated by line breaks. Data Merge gets confused with this option.
My fourth approach was to have separate text boxes for the two lists, which have the data elements inserted like in my first approach. The problem with this is that the two lists are a fixed length apart, creating issues with very short lists and very long lists (the short ones have a lot of empty space in between, the long ones overflow the text box)
Data Merge is not a terrifically sophisticated tool, and it sounds like what you're trying to do here is pushing it beyond where it was designed to go.
I see three approaches that could work, and one that may or may not. Two of them are workarounds:
Apply a single paragraph style to the lot, then use Search/Replace to change the paragraph style of list headings.
Use the above, then run a script rather than manually doing search/replace.
The third, and probably most workable in the long term, is to use an XML-based approach rather than Data Merge. This involves setting up an XML template for the document, then formatting your input data as XML rather than CSV. XML in InDesign allows for nested data with arbitrary numbers of members, and can be output from a database or (with a bit of setup work) a spreadsheet.