Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: gigamonkey/markup
base: 59a98f3350
...
head fork: gigamonkey/markup
compare: 3f617411e9
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 68 additions and 21 deletions.
  1. +8 −7 README
  2. +59 −13 markup-spec.txt
  3. +1 −1  markup.rb
View
15 README
@@ -1,6 +1,6 @@
-[N.B. This is a work in progress of a new implementation. Not yet
-ready for use. Oh, and this is the first Ruby code I've ever written
-so if it looks stupid, that might be why.]
+[This is a work in progress of a new implementation. It getting close
+to being ready for use. Oh, and this is the first Ruby code I've ever
+written so if it looks stupid, that might be why. Comments welcome.]
Markup is a text markup language primarily useful for prose documents
such as books and articles. It is designed to be editable in a plain
@@ -10,9 +10,10 @@ The grammar of a Markup file is defined in terms of a mapping to an
abstract syntax tree which can then be rendered into a number of
formats, e.g. HTML, PDF, TeX, RTF, etc.
-This project will contain implementations of Markup processors in
-various languages. See also [1] for a Common Lisp implementation that
-evolved out of the one I used while working on my two books, Practical
-Common Lisp and Coders at Work, both of which were written in Markup.
+The full specificiation of Markup is in markup-spec.txt (which is
+itself written in Markup). See also [1] for a Common Lisp
+implementation that evolved out of the one I used while working on my
+two books, Practical Common Lisp and Coders at Work, both of which
+were written in Markup.
[1] https://github.com/gigamonkey/monkeylib-markup
View
72 markup-spec.txt
@@ -88,16 +88,18 @@ Verbatim sections are tagged with \code{pre}.
*** Lists
Lists are demarcated by two spaces of indentation followed by a list
-marker, either ‘\code{#}’ for an ordered (i.e. numbered) list or
-‘\code{-}’ for an unordered (i.e. bulleted) list. An ordered list is
-tagged with \code{ol} and an unordered list with \code{ul}.
+marker, either ‘\code{#}’ for an ordered (i.e. numbered) list,
+‘\code{-}’ for an unordered (i.e. bulleted) list, or ‘\code{%}’ for a
+definition list. An ordered list is tagged with \code{ol}, an
+unordered list with \code{ul}, and a definition list with \code{dl}.
The list marker must be followed by a space and then the text of the
-first list item. List items are tagged with \code{li} and can contain
-multiple paragraphs, the contents of which are indented to line up
-under first character of the beginning of the list item. Subsequent
-items are marked with another list marker in the same column as the
-original list marker and another space. For example:
+first list item. For ordered and unordered List items are tagged with
+\code{li} and can contain multiple paragraphs, the contents of which
+are indented to line up under first character of the beginning of the
+list item. Subsequent items are marked with another list marker in the
+same column as the original list marker and another space. For
+example:
This is a regular paragraph.
@@ -135,6 +137,31 @@ Could be rendered in HTML as:
<p>This is another paragraph.</p>
+For definition lists, the term (tagged with \code{dt}) must go on one
+line and is ended with another ‘\code{%}’. The definition (tagged with
+\code{dd}) starts on the next line and can consist of multiple
+paragraphs. For example this markup:
+
+ % frob %
+ Abbreviated form of frobnicate.
+
+ % frobnicate %
+ To manipulate or adjust, to tweak.
+
+Could be rendered in HTML as:
+
+ <dl>
+ <dt>frob</dt>
+ <dd>
+ <p>Abbreviated form of frobnicate.</p>
+ </dd>
+
+ <dt>frobnicate</dt>
+ <dd>
+ <p>To manipulate or adjust, to tweak.</p>
+ </dd>
+ </dl>
+
*** Links
A Markup processor can optionally support a few bits of syntax to make
@@ -159,7 +186,7 @@ when parsing a given document.
*** Tagged markup
-For all other markup, Markup uses the TeX-like notation
+For most other markup, Markup uses the TeX-like notation
\code{\\\i{tagname}\{\i{stuff}\}}. Tag names can consist of letters,
numbers, ‘\code{-}’, ‘\code{.}’, and ‘\code{+}’. Tagged markup can
nest so you can have:
@@ -202,6 +229,29 @@ A Markup processor will need to provide some more or less convenient
way to specify that certain tag names should be parsed as
sub-documents rather than character markup.
+*** Tagged sections
+
+Another way to tag a section of a document is with a line like:
+
+ ## foo
+
+followed by any elements that are legal at the top level of a
+document and finaly closed by:
+
+ ##.
+
+This will create a subdocument element with the tag \code{foo} and
+children of whatever paragraphs are between the opening and closing
+markers. This is sometimes more aesthetic than the equivalent:
+
+ \foo{
+
+ <stuff here>
+
+ }
+
+and doesn’t require telling the parser that \code{foo} is a
+subdocument tag.
*** Escapes
@@ -260,7 +310,3 @@ maps to (indentation for clarity):
<h2>Header 2</h2>
<p>Regular paragraph. With <i>italic</i> text.</p>
</body>
-
-
-
-
View
2  markup.rb
@@ -666,7 +666,7 @@ def grok(token)
when @value
@block.call
else
- raise "Parse error expected <#{@value}> got #{token.value}"
+ raise "Parse error expected <#{@value}> got #{token.value} at #{token.line}:#{token.column}"
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.