Ejemplo n.º 1
0
		public static void Write(Paragraph para, TextWriter w)
		{
			Debug.Assert(para.block.Lines.Count == 1);
			Write(para.block.Lines[0], w);
			w.WriteLine();
			w.WriteLine();
		}
Ejemplo n.º 2
0
		public static List<Element> Assemble(List<Block> blocks)
		{
			Block previous		= null;
			Verse previousVerse = null;
			Quote previousQuote = null;

			List<Element> elements = new List<Element>();

			foreach (Block block in blocks) {
				Element element = null;

				if (block.Verse) {
					if (previous != null && previous.Tied && previous.Verse) {
						Debug.Assert(previousVerse != null);
						previousVerse.blocks.Add(block);
					} else {
						previousVerse = new Verse();
						previousVerse.blocks.Add(block);
						element = previousVerse;
					}
				}
				else if (block.Heading.HasValue) {
					Heading head = new Heading();
					Debug.Assert(block.Lines.Count == 1);
					head.Title = block.Lines[0];
					head.Depth = block.Heading.Value;
					element = head;
				}
				else if (block.Footnote.HasValue) {
					Footnote fn = new Footnote();
					fn.Text	 = block;
					fn.Index = block.Footnote.Value;
					element = fn;
				}
				else {
					Paragraph para = new Paragraph();
					para.block = block;
					element = para;
				}

				bool added = false;

				if (block.Quoted && element != null) {
					if (previous != null && previous.Tied && previous.Quoted) {
						Debug.Assert(previousQuote != null);
						previousQuote.elements.Add(element);
						added = true;
					} else {
						previousQuote = new Quote();
						previousQuote.elements.Add(element);
						element = previousQuote;
					}
				}

				if (! added && element != null)
					elements.Add(element);

				previous = block;
			}

			return elements;
		}