public bool Process(TextDocument doc) {
      bool changes = false;

      List<TextBlock> blocks = doc.TextBlocks;
      var blocksNew = new List<TextBlock>();

      foreach (TextBlock tb in blocks) {
        string text = tb.Text;
        string[] paragraphs = Regex.Split(text, "[\n\r]+");
        if (paragraphs.Length < 2) {
          blocksNew.Add(tb);
          continue;
        }
        bool isContent = tb.IsContent;
        List<string> labels = (tb.Labels ?? Enumerable.Empty<string>()).ToList();
        foreach (String p in paragraphs) {
          var tbP = new TextBlock(p) { IsContent = isContent };
          tbP.AddLabels(labels);
          blocksNew.Add(tbP);
          changes = true;
        }
      }

      if (changes) {
        blocks.Clear();
        blocks.AddRange(blocksNew);
      }

      return changes;
    }
示例#2
0
 protected virtual void AddLabelsTo(TextBlock tb) {
   tb.AddLabels(Labels);
 }