Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MarkdownToHtml.cs
1using System.Threading.Tasks;
2using Waher.Script;
6
8{
13 {
23 {
24 }
25
29 public override string FunctionName => nameof(MarkdownToHtml);
30
35 public override bool IsAsynchronous => true;
36
44 {
45 return this.EvaluateScalarAsync(Argument, Variables).Result;
46 }
47
54 public override async Task<IElement> EvaluateScalarAsync(string Argument, Variables Variables)
55 {
56 return new StringValue(await ToHtml(Argument, Variables));
57 }
58
64 public static Task<string> ToHtml(string Markdown)
65 {
66 return ToHtml(Markdown, null);
67 }
68
75 public static async Task<string> ToHtml(string Markdown, Variables Variables)
76 {
78
79 Markdown = "BodyOnly: 1\r\n\r\n" + Markdown;
80
81 if (Variables is null)
82 Doc = await MarkdownDocument.CreateAsync(Markdown);
84 v.ValueObject is MarkdownSettings Settings)
85 {
86 Doc = await MarkdownDocument.CreateAsync(Markdown, Settings);
87 }
88 else
89 {
90 Settings = new MarkdownSettings()
91 {
93 };
94
95 Doc = await MarkdownDocument.CreateAsync(Markdown, Settings);
96 }
97
98 return await Doc.GenerateHTML();
99 }
100
101 }
102}
override IElement EvaluateScalar(string Argument, Variables Variables)
Evaluates the function on a scalar argument.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
static async Task< string > ToHtml(string Markdown, Variables Variables)
Converts a Markdown snippet to a HTML snippet.
static Task< string > ToHtml(string Markdown)
Converts a Markdown snippet to a HTML snippet.
MarkdownToHtml(ScriptNode Argument, int Start, int Length, Expression Expression)
MarkdownToHtml(x)
override string FunctionName
Name of the function
override async Task< IElement > EvaluateScalarAsync(string Argument, Variables Variables)
Evaluates the function on a scalar argument.
Contains a markdown document. This markdown document class supports original markdown,...
const string MarkdownSettingsVariableName
Variable name used for storing Markdown settings.
async Task< string > GenerateHTML()
Generates HTML from the markdown text.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
Contains settings that the Markdown parser uses to customize its behavior.
Class managing a script expression.
Definition: Expression.cs:39
Base class for funcions of one scalar variable.
ScriptNode Argument
Function argument.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Contains information about a variable.
Definition: Variable.cs:10
Collection of variables.
Definition: Variables.cs:25
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
Definition: Variables.cs:52
Basic interface for all types of elements.
Definition: IElement.cs:20