I am developing a plug-in that merges segments into one. Some segments contain auto-cloned tag pairs, e.g.:
This is a <pt15>test</pt15>:
<pt15>Attention</pt15>!
When merged the consolidated segment looks like this:
This is a <pt15>test</pt15>: <pt15>Attention</pt15>!
But it should look like this, which is what you also get when merging those segments in Studio manually.
This is a <pt15>test: Attention</pt15>!
For merging I am using a function that looks as shown below. The MoveAllItemsTo method also inserts the tags with the sdl:autoclone property into the enlarged segment. Can anyone think of an easy way to exclude the auto-cloned tags?
private void MergeFunction(IParagraph paragraph)
{
var segments = from item in paragraph
where item is ISegment
select item as ISegment;
int i = 0;
segments.ToList().ForEach(item =>
{
i++;
var sourceSegmentPosition = item.IndexInParent;
if (i > 1)
{
item.MoveAllItemsTo((IAbstractMarkupDataContainer)segments.First());
item.RemoveFromParent();
item.MoveAllItemsTo(paragraph, sourceSegmentPosition);
}
});
}