Writing Blog in Markdown with Ada Parser


Writing Blog in Markdown with Ada Parser

I have created a simple blog engine/parser in Ada that converts Markdown files into a static website. Currently, the parser supports basic Markdown features. Inlines: bold, italic, combination, code, links. images.

I had ready-made building blocks for creating a static site generator:

All that was left was to put everything together and add the HTML and CSS, which Gemini helped me create.

Currently, VSS doesn't have its own XML parser, and it's needed to store templates. VSS suggests using a parser from XmlAda or Matreshka, but I didn't want to add these dependencies. Since the template rarely changes, I 🤡 decided to simply read it using Python, which I already have, and generate Ada code that would return the data that XML Parser would have returned:

<head>
    <meta charset="UTF-8"/>
procedure Vyasa.Templates.Index
  (CH : in out VSS.XML.Content_Handlers.SAX_Content_Handler'Class;
   Ok : in out Boolean)
is
begin
--  ...
declare
   Attr : VSS.XML.Attributes.Containers.Attributes;
begin
   CH.Start_Element (+"http://www.w3.org/1999/xhtml", "head", Attr, Ok);
end;
CH.Characters (New_Line, Ok);
CH.Characters ("    ", Ok);
declare
   Attr : VSS.XML.Attributes.Containers.Attributes;
begin
   Attr.Insert (+"", "charset", "UTF-8");
   CH.Start_Element (+"http://www.w3.org/1999/xhtml", "meta", Attr, Ok);
end;
--  ...

It would be nice to add RSS feed support, commenting capabilities, and syntax coloring, etc.

Block examples

Alt text

Hard line break
New line after two spaces.


Blocks:

Header (2 level)

  • List item 1
  • List item 2
  1. Numbered item 1
  2. Numbered item 2

Quote block

-- Code block
with Ada.Text_IO;