Beispiel #1
0
        private List <int> CalculateWidths(TableHeaderCollection headers, TableRowCollection rows, int columnCount)
        {
            var widths = new List <int>();

            int index = 0;

            var mb = new MarkdownBuilder(Settings);

            if (headers != null)
            {
                foreach (TableHeader header in headers)
                {
                    mb.Append(header.Name);
                    widths.Add(mb.Length - index);
                    index = mb.Length;
                }
            }

            foreach (TableRow row in rows)
            {
                for (int i = 0; i < row.Count; i++)
                {
                    mb.Append(row[i]);
                    widths.Add(mb.Length - index);
                    index = mb.Length;
                }
            }

            int count = widths.Count;

            var maxWidths = new List <int>();

            for (int i = 0; i < columnCount; i++)
            {
                maxWidths.Add(0);

                for (int j = i; j < count; j += columnCount)
                {
                    maxWidths[i] = Math.Max(maxWidths[i], widths[j]);
                }
            }

            return(maxWidths);
        }
Beispiel #2
0
        public MarkdownBuilder AppendTo(MarkdownBuilder mb)
        {
            bool isFirst = true;

            foreach (object value in Values)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    mb.Append(Separator, escape: Escape);
                }

                mb.Append(value, escape: Escape);
            }

            return(mb);
        }