gml

package
v0.0.0-...-00f0b3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2022 License: 0BSD Imports: 8 Imported by: 0

README

#+title: The Gutenblog Markup Language
#+date: March 16, 2022
#+options: toc:nil

I want to build a website generator, but first I need a markup
language. I like org-mode and markdown but they each have enough
quirks that I don't want to use them for this project.

For Gutenblog v1.0 I chose to use raw, unaltered HTML. This was the
simplest to implement and offered the most flexibility for publishing
web pages but it much less ergonomic than using something like markdown.

So I decided to implement my own markup language that bridges the this
gap. GML is mostly focused on block-level elements and defers all
inline-styling to HTML. There are far too many edge-cases around
translating typographical elements out of plain-text that it's really
not worth it when HTML is what we want in the end anyway.

* Examples
GML Example:
#+begin_example
#+end_example

Output as HTML:
#+begin_src html
#+end_src

* GML Grammar (BNF)
This is the grammar I came up with for brainstorming GML. I hope it's
relatively complete but there are probably a few gaps.

#+begin_example
<document> ::= <metadata> <content> <eof>

<metadata> ::= <key> <value> <eol>
             | <key> <value> <eol> <metadata>

<content> ::= <block>
            | <block> <block>

<block> ::= <heading> <styled-text> <eol>
          | <paragraph>
          | <list>
          | <blockquote>
          | <figure>
          | <pre>
          | <html>
          | <footnotes>

<paragraph> ::= <styled-text> <empty-line>
              | <styled-text> <styled-text>

<blockquote> ::= "%blockquote" <eol> <styled-text> <empty-line>

<figure> ::= "%figure" <arguments> <eol> <html> <eol> <caption> <empty-line>

<pre> ::= "%pre" <eol> <text> <empty-line>

<html> ::= "%html" <eol> <text> <empty-line>

<footnotes> ::= "%footnotes" <eol> <list>

<styled-text> ::= <text>
                | <url>
                | <html>
                | <footnote>

<list> ::= <list-item> <empty-line>
         | <list-item> <list-item>

<list-item> ::= "-" <styled-text> <eol>
              | <number> "." <styled-text> <eol>

<footnote> ::= ""
             | "[fn:" <number> "]"

<url> ::= "https://" <text> <space>

<key> ::= "%title"
        | "%subtitle"
        | "%date"

<heading> ::= "*"
            | "**"
            | "***"

<arguments> ::= ""
              | <text>

<caption> ::= ""
            | <text>

<value> ::= <text>
<html> ::= <text>
#+end_example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document interface {
	Title() string
	Subtitle() string
	Date() time.Time
	HTML(opts *HTMLOptions) string
}

The idea here is to transform a GML document into HTML.

func Parse

func Parse(s string) (Document, error)

type HTMLOptions

type HTMLOptions struct {
	Minified bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL