]> OzVa Git service - gn-parser/summary
 
descriptionParser for .gn "Goodnight" files
last changeSun, 18 May 2025 14:19:43 +0000 (15:19 +0100)
readme

The Goodnight Markdown Specification - Version 0.1.0

Goodnight Publishing

10 May 2025

Table of Contents

  1. Section 1 - Reasoning
  2. Section 2 - Features
    1. (2.1) Headings
    2. (2.2) Links
    3. (2.3) Paragraphs
    4. (2.4) Images
    5. (2.5) Code
    6. (2.6) Block quotes
    7. (2.7) Inline formatting
    8. (2.8) Lists
    9. (2.9) Macros
    10. (2.10) Metadata
    11. (2.11) Referencing
    12. (2.12) Maths

Reasoning

There are currently a number of tools for writing.

I was important, when designing Goodnight, to think what might be the responsibility of the parser, the stylesheet and the user. For example, although horizontal lines are almost always a common feature in Markdown flavors, I belive it is the responsibility of the stylesheet.

Features

Along with the features below, some features where removed:

I don't belive in line breaks and horizontal rules are the responsibility of the stylesheet.

Headings

Headings are prefixed with the # hastag character as with standard markdown. There must not be a space before the # character. This can go up to five hashtag "levels". For LaTeX, this is: section, subsection, subsubsection, paragraph and subparagraph. For HTML, although there are normaly six levels of heading (h1 - h6), the first is reserved for the title so "level one" translates to h2. Additionally, the title of the heading (lowercase and seperated by hyphens) is used as the anchor text for reference in the table of contents. For gemtext, there are normally no more than 3 levels, of which one is reserved for the title, so only 2 are used. In the case of gemtext, the table of contents will still refelect the sematic order of document up to the normal 5 levels. A space may or may not be put after the #. Inline formatting will be properly parsed. Inline references will be properly parsed.

Example:

## Goodnight!

In LaTeX:

\subsection{Goodnight!}

In HTML:

<h3 id="goodnight!">Goodnight!</h3>

In gemtext:

### Goodnight!

Links look similar to how images are implemented in markdown, but instead of an exclaimation mark, = is used. This can only be done at the start of a line. There are also more feilds than that of images, these mean the following:

=[Caption][LaTeX link][HTML link][gemtext link]

or...

=[LaTeX link][HTML link][gemtext link]

or...

=[Caption][Universal link]

or...

=[Universal link]

This is because different formats might require different link locations. Format agnostic links are still possible for ease of writing or if the file in specific to one format.

Paragraphs

A paragraph is any line that does not start with one of the following: #-. or ``` or one of the macros such as [TOC]

Images

As in conventional markdown, images are represented with square backets, preceeded by an exclaimation mark. This must begin on the first character of a newline. The image caption is captured in the first set of square brackets, with the path to the image captured in the second. In LaTeX, this renders as an image centered in a figure enviroment with the figure caption contained in the first pair of brackets. In HTML this renders as an image in a <figure> tag, with a <figcaption> containing the caption. In gemtext this is simply a link to the path provided with the caption as the link text.

Example:

![Goodnight][images/goodnight.png]

In LaTeX:

\begin{figure}
	\centering
	\includegraphics[width=0.7\textwidth]{images/goodnight.png}
	\caption{Goodnight}
\end{figure}

In HTML:

<figure>
	<img src='images/goodnight.png' />
	<figcaption>Goodnight</figcaption>
</figure>

In gemtext:

=> <images/goodnight.png> Goodnight (image)

Code

Inline code blocks can be used with the ` backtick character. In LaTeX this becomes \texttt{...}, in html this becomes <code>...</code> and in gemtext it is included as written. A bar character cannot currently be used in an inline code block.

Code blocks can be used with three backtick characters: ```. This sequence must start on the first character on a new line. This is parsed into the <pre> HTML tag, the verbatim LaTeX enviroment and the gemtext code block enviroment (also bookended by three backticks).

Block quotes

Block quotes are started with the tab character t. They can contain any other elements.

This is a paragraph within a blockquote

  • This is a list element in a blockquote

Tabbed lines with a space between them are joined into one single blockquote. If two different blockquotes are needed next to each other, a backslash at the first character of a newline can split the two up.

This is parsed into the HTML quote tag, the LaTeX quote enviroment and the gemtext block quote enviroment (where every line is preceeeded by a > symbol).

Inline formatting

Bold styling is done with a single * character surrounding the bold text. This is parsed to \textbf and <b> respectively with inline formatting not supported in gemtext.

Italic styling is done with a single _ character surrounding the italicised text. This is parsed to \textit and <em> respectively with inline formatting not supported in gemtext.

Lists

In HTML and LaTeX, lists are parsed directly to list markup with no complications (enumerate, itemize and \item for LaTeX and <ol>, <ul> and <li> for HTML). In gemtext, both type of list item is included prefixed with a * character and no nesting is needed.

Ordered lists will work only with the period character. They are numbered by the browser in the case of HTML, or externally by the LaTeX compiler in the case of LaTeX. Gemtext does not support ordered lists so the parser numbers the list elements in plaintext. Ordered lists can be broken up by including a blank line between two lists.

Macros

To generate the title, table of contents and bibliography, the following macros can be used at the first character of a newline:

In LaTeX, the title and bibliography are styled by the parser, rather than the native \maketitle or \printbibliography command. The table of contents is generated by the LaTeX compiler natively. In HTML and gemtext, the title, table of contents and references are all styled by the parser.

Note that in HTML, <hgroup> is used for a semantic title block and the <h1> tag is used for the title only and in gemtext the first heading level is used for the title only.

Metadata

The metadata format used is the YAML format. To generate the title, the standard LaTeX keys of "title", "author" and "date", should be used. If "style" is used, the parser will introduce the stylesheet with the relevant extension. For example, style: stylesheet will introduce stylesheet.css for html and stylesheet.sty for LaTeX.

Example:

---
title: The Goodnight Markdown Specification - Version 0.1.0
author: Goodnight Publishing
additional_information: This is some additional information
---

Referencing

All referencing in Goodnight is APA 7th. Everything is the reference list is listed in the bibliography, even works not included in the text, so you are resposible for making sure this lines up with your work.

Each reference can happen anywhere in the text, begining with the ID for the reference. This ID can then be used in the body of the text to produce the inline reference. The text of the ID is arbitrary but can only contain alphanumeric characters. If "title" or "author" are used in square brackets directly after the inline id (for example [goodnight][author]) then that feild will be printed in the text. Following the ID, each on a new line, are a set of "keys" which describe the work.

Example:

[goodnight][author] ([goodnight][year]) writes "Each reference can happen anywhere in the text"

\[goodnight]
title: The Goodnight Markdown Specification - Version 0.1.0
author: Goodnight Publishing
url: https://goodnight-publishing.co.uk

Becomes:

Goodnight Publishing (n.d.) writes "Each reference can happen anywhere in the text"

The keys are as follows:

  1. author. The authors or entities behind the work seperated by the word "and". Wrap entity names in curly brackets
  2. title
  3. year. "n.d." used if no year is given. (optional)
  4. publisher (optional)
  5. url (optional)
  6. journaltitle: Title of the book or journal the work is in (optional)
  7. issuetitle: Issue title of the book or journal the work is in (optional, must be used with journaltitle)
  8. editor: Author of the book or journal the work is in. Should be formatted the same as "author". (optional, must be used with journaltitle)
  9. volume: Volume of the book or journal the work is in. Example: "7th". (optional, must be used with journaltitle)

Maths

Math mode has yet to be implemented.

shortlog
2025-05-18 Max ValueFixed subtract overflow bugs main
2025-05-18 Max ValueChanged deps
2025-05-18 Max ValueAdded images and links
2025-05-10 Max ValueFixed some inline parser bugs and added stylesheet
2025-05-09 Max ValueMetdata changes
2025-05-09 Max ValueAdded proper TOC for HTML and gem
2025-05-07 Max ValueAdded parse plaintext and word count to metadata
2025-05-07 Max ValueSee last commit
2025-05-07 Max ValueFinished all current elementes
2025-05-03 Max ValueAdded elements
2025-05-02 Max ValueFramework
2025-05-01 Max ValueInit
heads
3 months ago main