Scribbly format. ANTLR syntax + Java library.
Go to file
Feufochmar 2151fbcd53 Update dependencies. 2023-12-29 12:05:00 +01:00
src/main To accept a syntax '@command some text', the space character should be treated separately from STRING and WS. 2023-06-03 12:38:44 +02:00
.gitignore Initialize fr.feufochmar.scribbly library. 2023-05-19 20:40:22 +02:00
.project Initialize fr.feufochmar.scribbly library. 2023-05-19 20:40:22 +02:00
README.md Complete the README with explainations on the Java library. 2023-08-17 16:24:59 +02:00
pom.xml Update dependencies. 2023-12-29 12:05:00 +01:00

README.md

Scribbly format

The Scribbly text format is a document format whose syntax is inspired by the Scribble documentation format of Racket. The format is basically plain text enhanced with commands indicating the context. In the Scribbly format, the commands are introduced by a @, can take named parameters introduced between [ and ] and be applied to a section of Scribbly text delimited by { and }.

An example of a Scribbly document:

@document
[title:Scribbly example]
{
  An example of a Scribbly document. @newline
  The character @unicode[point:26C4] represents a snowman.
  @style[color:red][bold:true]{An important message}: @large{snowmen melt in the sun}.
}

The Scribbly format does not interpret the commands. It's up to the application using the format to define them, their meaning and their parameters.

The commands and parameter names are limited to the latin lowercase alphabetic characters. The characters @, [, ], { and } must be escaped with a prefixing @ if they are not part of a command.

Compiling the Java library

The Java library for manipulating Scribbly text can be compiled using maven. It uses the standard commands (clean, package, install).

mvn clean package
mvn install

The Java API

The classes are in the fr.feufochmar.scribbly namespace. A Scribbly document is represented by the ScribblyDocument class, which contain a list of ScribblyElement. A Scribbly element is either a ScribblyCommand (representing a command, its parameters, and the list of ScribblyElements on which it apply) or a ScribblyText (representing text outside commands). A Scribbly document is processed using the visitor patter, using an instance of the ScribblyVisitor interface. The ScribblyDocumentParser class can be used to build a ScribblyDocument from a file, input stream or reader. The ScribblyDocumentWriter is an example of ScribblyVisitor implementation allowing to write a ScribblyDocument into an output stream or writer.