Marker: A language for links
#lang marker | package: marker |
Marker is a programming language designed to make representing collections of links easier than ever. Think something like a bookmarks bar in your browser or a linktree link. Marker allows this collection of links to be read and interpreted as Racket data, thus enabling all sorts of interesting operations on them. The main use of Marker is to provide a common format to which other formats can be easily compiled. This document will walk you through the basics of writing Marker documents and compiling them to a few common formats.
1 Marker Quick Reference
Marker is a very small programming language. That being said, it features pretty much all the functionality you’d need in its rather small domain. The following is a comprehensive list of all the functionality present in Marker:
1.1 Defining a bookmark
syntax
(name url)
name = <String> url = <String>
The following are examples of bookmarks being defined in Marker:
#lang marker ("Google" "https://google.com") ("Racket" "https://racket-lang.org") ("Blank Page" "about:blank")
1.2 Defining a folder
syntax
[name entries ...]
name = <String> entries = <Marker-Entry>
The following are examples of folders being defined in Marker:
#lang marker ["Search" ("Google" "https://google.com") ("Bing" "https://bing.com")] ["Read" ("Wikipedia" "https://wikipedia.org") ("Project Gutenberg" "https://gutenberg.org")] ["Folder" ["In a Folder" ["In Another Folder" ("Hello" "about:blank")]]]
1.3 Requiring other files
syntax
(require path-to-other-file)
path-to-other-file = <String>
This works almost exactly as it does in base Racket or any other programming language where you can import external libraries. The following illustrates how require works:
#lang marker ;; In file: require.mrkr ("Required Bookmark" "about:blank")
#lang marker ;; In file: main.mrkr (require "require.mrkr") ["Folder" (require "require.mrkr")]
Becomes after requiring:
#lang marker ("Required Bookmark" "about:blank") ["Folder" ("Required Bookmark" "about:blank")]
1.4 Comments
Like in Racket, the following comments are valid in Marker:
#lang marker ; Single line comment #| multi line comment |# #;(comment the whole s-expression)
2 Compiling Marker to Other Formats
The power of Marker comes from its ability to easily compile into many other formats. There are three generators currently provided with the base install of Marker:
Plain text - Folders and Links are represented with plain text.
HTML - Folders and Links are represented as hyperlinks on a webpage.
Netscape - Folders and Links are represented as bookmarks, suitable for import into Firefox or Chrome
Marker generators are typically installed as raco commands. This means to run any generator, you usually use a command like "raco marker-format [file]" which will take the given Marker file and convert it into the format.
If you are interested in writing a custom generator, please see the documentation for marker-lib, which discusses more if the inner workings of Marker.
2.1 Compiling Marker to Plain Text
To compile Marker to plain text, simply use the "marker-text" raco command. The following is an example of converting a Marker document into plain text.
#lang marker ;; In file: example.mrkr ("Marker" "https://github.com/bravotic/marker") ("Google" "https://google.com") ["Racket" ("Website" "https://racket-lang.org") ("Docs" "https://docs.racket-lang.org")]
After running the following command...
$ raco marker-text example.mrkr
the Marker document is compiled to:
Marker: https://github.com/bravotic/marker Google: https://google.com Racket: | Website: https://racket-lang.org | Docs: https://docs.racket-lang.org
2.2 Compiling Marker to HTML
Like plain text, the command "marker-html" can be used to compile Marker to a basic HTML webpage. The following is an example of a Marker document being compiled to HTML:
#lang marker ;; In file: example.mrkr ("Marker" "https://github.com/bravotic/marker") ("Google" "https://google.com") ["Racket" ("Website" "https://racket-lang.org") ("Docs" "https://docs.racket-lang.org")]
After running the following command...
$ raco marker-html example.mrkr
the Marker document is compiled to:
<html> <body> <h1>Bookmarks</h1> <li><a href="https://github.com/bravotic/marker"><img height=16 width=16 src="https://github.com/favicon.ico">Marker</a></li> <li><a href="https://google.com"><img height=16 width=16 src="https://google.com/favicon.ico">Google</a></li> <h2>Racket</h2> <ul style="border-left: 2px dashed black;"><li><a href="https://racket-lang.org"><img height=16 width=16 src="https://racket-lang.org/favicon.ico">Website</a></li> <li><a href="https://docs.racket-lang.org"><img height=16 width=16 src="https://docs.racket-lang.org/favicon.ico">Docs</a></li> </ul> </body> </html>
2.3 Compiling Marker to Netscape Bookmarks
The Netscape bookmark format is the HTML based format both Firefox and Chrome use to store and export bookmarks. Marker can export to this format which makes it easy to import into any modern browser. To compile to this format, we follow the same steps as both plain text or HTML, except this time using the command "marker-netscape" as follows:
#lang marker ;; In file: example.mrkr ("Marker" "https://github.com/bravotic/marker") ("Google" "https://google.com") ["Racket" ("Website" "https://racket-lang.org") ("Docs" "https://docs.racket-lang.org")]
After running the following command...
$ raco marker-html example.mrkr
the Marker document is compiled to:
<!DOCTYPE NETSCAPE-Bookmark-file-1> <!-- This is an automatically generated file. It will be read and overwritten. DO NOT EDIT! --> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> <TITLE>Bookmarks</TITLE> <H1>Bookmarks</H1> <DL><p> <DT><A HREF="https://github.com/bravotic/marker" ADD_DATE="0" LAST_MODIFIED="0">Marker</A> <DT><A HREF="https://google.com" ADD_DATE="0" LAST_MODIFIED="0">Google</A> <DT><H3 ADD_DATE="0" LAST_MODIFIED="0">Racket</H3> <DL><p> <DT><A HREF="https://racket-lang.org" ADD_DATE="0" LAST_MODIFIED="0">Website</A> <DT><A HREF="https://docs.racket-lang.org" ADD_DATE="0" LAST_MODIFIED="0">Docs</A> </DL><p> </DL><p>