Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MarkdownElement.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
5
7{
12 {
16 Center,
17
21 Baseline
22 }
23
27 public abstract class MarkdownElement
28 {
29 private readonly MarkdownDocument document;
30
36 {
37 this.document = Document;
38 }
39
43 public MarkdownDocument Document => this.document;
44
48 public virtual IEnumerable<MarkdownElement> Children => new MarkdownElement[0];
49
53 public virtual bool IsBlockElement => false;
54
61 public virtual bool SameMetaData(MarkdownElement E)
62 {
63 return this.GetType() == E.GetType();
64 }
65
71 public override bool Equals(object obj)
72 {
73 return this.GetType().Equals(obj.GetType());
74 }
75
80 public override int GetHashCode()
81 {
82 return this.GetType().GetHashCode();
83 }
84
89 public abstract Task Render(IRenderer Output);
90
94 public virtual bool OutsideParagraph => false;
95
99 public abstract bool InlineSpanElement
100 {
101 get;
102 }
103
108
115 public virtual bool ForEach(MarkdownElementHandler Callback, object State)
116 {
117 return Callback(this, State);
118 }
119
126 protected static bool AreEqual(Array Items1, Array Items2)
127 {
128 int i, c = Items1.Length;
129 if (Items2.Length != c)
130 return false;
131
132 for (i = 0; i < c; i++)
133 {
134 if (!Items1.GetValue(i)?.Equals(Items2.GetValue(i)) ?? Items2.GetValue(i) is null)
135 return false;
136 }
137
138 return true;
139 }
140
146 protected static int GetHashCode(Array Items)
147 {
148 int h1 = 0;
149 int h2;
150
151 foreach (object Item in Items)
152 {
153 h2 = Item?.GetHashCode() ?? 0;
154 h1 = ((h1 << 5) + h1) ^ h2;
155 }
156
157 return h1;
158 }
159
161 public override string ToString()
162 {
164 {
165 this.Render(Renderer);
166 return Renderer.ToString();
167 }
168 }
169
174 public abstract void IncrementStatistics(MarkdownStatistics Statistics);
175
176 }
177}
Contains a markdown document. This markdown document class supports original markdown,...
Contains some basic statistical information about a Markdown document.
Abstract base class for all markdown elements.
static int GetHashCode(Array Items)
Calculates a hash value on an array.
virtual bool ForEach(MarkdownElementHandler Callback, object State)
Loops through all child-elements for the element.
override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
virtual bool SameMetaData(MarkdownElement E)
If the current object has same meta-data as E (but not necessarily same content).
virtual bool IsBlockElement
If the element is a block element.
abstract void IncrementStatistics(MarkdownStatistics Statistics)
Increments the property or properties in Statistics corresponding to the element.
abstract Task Render(IRenderer Output)
Renders the element.
virtual IEnumerable< MarkdownElement > Children
Any children of the element.
abstract bool InlineSpanElement
If the element is an inline span element.
override int GetHashCode()
Serves as the default hash function.
virtual bool OutsideParagraph
If element, parsed as a span element, can stand outside of a paragraph if alone in it.
MarkdownDocument Document
Markdown document.
static bool AreEqual(Array Items1, Array Items2)
Checks if two typed arrays are equal
MarkdownElement(MarkdownDocument Document)
Abstract base class for all markdown elements.
Renders portable Markdown from a Markdown document.
Abstract base class for Markdown renderers.
Definition: Renderer.cs:14
override string ToString()
Returns the renderer output.
Definition: Renderer.cs:130
Interface for Markdown renderers.
Definition: IRenderer.cs:12
BaselineAlignment
Where baselign of horizontally organized elements are rendered.
delegate bool MarkdownElementHandler(MarkdownElement Element, object State)
Delegate for markdown element callback methods.