The class MarkDown, as an “abstract class”, is purely a base class and defines an interface. It exists only so that Gambas programmers can inherit from it in their own classes → Chapter 24.7.1 Projects (Project 2) to write their particular variant of (Gambas) Markdown.
For example, one can write new special commands in the Command() method that do not exist in standard Markdown. In the Gambas Wiki, which runs on gambaswiki.org, new commands have also been implemented (in WikiMarkdown.Command()). For example, the information and warning boxes you see in the wiki or the red “Since 3.x” box are such special commands. The complete project can be found in the Gambas source files at /app/src/gambas-wiki if you have installed Gambas from the project sources.The Link() method gets a link of type MarkdownLink (→ Chapter 27.4.3 MarkDownLink) and converts it from MarkDown syntax to a correct HTML path specification. In the Gambas example project 'SmallWiki', exactly this is implemented in a separate class in the class file WikiMarkdown.class:
' Gambas class file Inherits Markdown Public Sub Link(hLink As MarkdownLink) Dim sPath As String If hLink.Link Begins "/" Then sPath = Mid$(hLink.Link, 2) Else If hLink.Link Begins "./" Then sPath = Request.Path &/ Mid$(hLink.Link, 3) Else Return Endif If Not hLink.Text Then If Main.IsImage(sPath) Then hLink.Html = "<img src=\"" & Application.Root &/ sPath & "?show\" />" Return Endif hLink.Text = Main.GetPageTitle(sPath) Endif hLink.Link = Application.Root &/ sPath End ' Link(hLink As MarkdownLink)
In the following source code you can see the basic implementation of the Markdown class:
' Gambas class file Export Create Public Root As String Public Line As Integer Public Current As String Public Sub ToHTML(Markdown As String) As String Return Markup.Convert(Markdown, Me) End Public Sub Link((sLink) As MarkdownLink) ' Link vom Typ MarkDownLink ' NOOP End Public Sub Command((sCommand) As String) As String[] ' NOOP End Public Sub Enter((sClass) As String) As String[] ' NOOP End Public Sub Leave((sClass) As String) As String[] ' NOOP End Public Sub EnableCode(Enabled As Boolean) If Enabled Then Inc Markup.EnableCode Else Dec Markup.EnableCode Endif End Public Sub CheckURL(URL As String, (Markup) As String) As String Return URL End