Skip to content

Commit

Permalink
Do list items with 1., not 0.
Browse files Browse the repository at this point in the history
See #5.
  • Loading branch information
domenic committed Sep 26, 2014
1 parent eab852c commit 85daf3b
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 69 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
**Ecmarkdown** is a Markdown-inspired syntax for writing algorithms in the style of the ECMAScript spec. This package will convert Ecmarkdown input to HTML output, allowing you to write

```
0. Assert: Type(_iterator_) is Object.
0. Assert: _completion_ is a Completion Record.
0. Let _hasReturn_ be HasProperty(_iterator_, "return").
0. ReturnIfAbrupt(_hasReturn_).
0. If _hasReturn_ is *true*, then
0. Let _innerResult_ be Invoke(_iterator_, "return", ( )).
0. If _completion_.[[type]] is not ~throw~ and _innerResult_.[[type]] is ~throw~, then
0. Return _innerResult_.
0. Return _completion_.
1. Assert: Type(_iterator_) is Object.
1. Assert: _completion_ is a Completion Record.
1. Let _hasReturn_ be HasProperty(_iterator_, "return").
1. ReturnIfAbrupt(_hasReturn_).
1. If _hasReturn_ is *true*, then
1. Let _innerResult_ be Invoke(_iterator_, "return", ( )).
1. If _completion_.[[type]] is not ~throw~ and _innerResult_.[[type]] is ~throw~, then
1. Return _innerResult_.
1. Return _completion_.
```

instead of
Expand Down Expand Up @@ -41,7 +41,7 @@ instead of

## Syntax

Every Ecmarkdown fragment is a **numeric list**. They are written as a series of lines, each starting with `0. `. Lines can be indented by multiples of exactly two spaces to indicate nesting.
Every Ecmarkdown fragment is a **numeric list**. They are written as a series of lines, each starting with `1. `. Lines can be indented by multiples of exactly two spaces to indicate nesting.

**Variables** are written as `_x_` and are translated to `<var>x</var>`. Variables cannot contain spaces, but can contain underscores.

Expand Down
2 changes: 1 addition & 1 deletion lib/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ list = lines:(dents listItem "\n")+ { ret

dents = spaces:" "* { return actions.dents(spaces, state); }

listItem = "0. " atoms:atom+ { return actions.listItem(atoms); }
listItem = "1. " atoms:atom+ { return actions.listItem(atoms); }

atom = variable
/ code
Expand Down
14 changes: 7 additions & 7 deletions test/cases/code.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0. Item `1`
0. Call `frob()`
0. The `stream.state` should be "readable".
0. "strings" are often in code, sometimes at the beginning.
0. `Code can contain spaces`.
0. Leftover backticks `code`cannot` get left there.
0. If they're balanced though, it works: `perhaps`unanticipated`?`.
1. Item `1`
1. Call `frob()`
1. The `stream.state` should be "readable".
1. "strings" are often in code, sometimes at the beginning.
1. `Code can contain spaces`.
1. Leftover backticks `code`cannot` get left there.
1. If they're balanced though, it works: `perhaps`unanticipated`?`.
18 changes: 9 additions & 9 deletions test/cases/iterator-close.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
0. Assert: Type(_iterator_) is Object.
0. Assert: _completion_ is a Completion Record.
0. Let _hasReturn_ be HasProperty(_iterator_, "return").
0. ReturnIfAbrupt(_hasReturn_).
0. If _hasReturn_ is *true*, then
0. Let _innerResult_ be Invoke(_iterator_, "return", ( )).
0. If _completion_.[[type]] is not ~throw~ and _innerResult_.[[type]] is ~throw~, then
0. Return _innerResult_.
0. Return _completion_.
1. Assert: Type(_iterator_) is Object.
1. Assert: _completion_ is a Completion Record.
1. Let _hasReturn_ be HasProperty(_iterator_, "return").
1. ReturnIfAbrupt(_hasReturn_).
1. If _hasReturn_ is *true*, then
1. Let _innerResult_ be Invoke(_iterator_, "return", ( )).
1. If _completion_.[[type]] is not ~throw~ and _innerResult_.[[type]] is ~throw~, then
1. Return _innerResult_.
1. Return _completion_.
6 changes: 3 additions & 3 deletions test/cases/list.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0. Item 1
0. Item 2
0. Item 3
1. Item 1
1. Item 2
1. Item 3
22 changes: 11 additions & 11 deletions test/cases/nested-list.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
0. Item 1
0. Item 1a
0. Item 1b
0. Item 2
0. Item 2a
0. Item 3
0. Item 4
0. Item 4a
0. Item 4ai
0. Item 4aii
0. Item 4b
1. Item 1
1. Item 1a
1. Item 1b
1. Item 2
1. Item 2a
1. Item 3
1. Item 4
1. Item 4a
1. Item 4ai
1. Item 4aii
1. Item 4b
16 changes: 8 additions & 8 deletions test/cases/nonterminals.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
0. |NonTerminalName|
0. |NonTerminalName_opt|
0. |NonTerminalName[Parameter1]|
0. |NonTerminalName[Parameter1, ?Parameter2]_opt|
0. at end |NonTerminalName[Parameter1, ?Parameter2]_opt|
0. |NonTerminalName[Parameter1, ?Parameter2]_opt| at start
0. in |NonTerminalName[Parameter1, ?Parameter2]_opt| middle
0. invalid |NonTerminalName_opt[Parameter1, ?Parameter2]|
1. |NonTerminalName|
1. |NonTerminalName_opt|
1. |NonTerminalName[Parameter1]|
1. |NonTerminalName[Parameter1, ?Parameter2]_opt|
1. at end |NonTerminalName[Parameter1, ?Parameter2]_opt|
1. |NonTerminalName[Parameter1, ?Parameter2]_opt| at start
1. in |NonTerminalName[Parameter1, ?Parameter2]_opt| middle
1. invalid |NonTerminalName_opt[Parameter1, ?Parameter2]|
12 changes: 6 additions & 6 deletions test/cases/spec-constants.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0. Add ~empty~ to the list
0. ~beginning~ constant
0. end ~value~
0. ~all~
0. ~multiple~ ~constants~ with ~some~ intermediate text ~sometimes~.
0. Spaces ~aren't allowed~ and cause it to be left as tildes.
1. Add ~empty~ to the list
1. ~beginning~ constant
1. end ~value~
1. ~all~
1. ~multiple~ ~constants~ with ~some~ intermediate text ~sometimes~.
1. Spaces ~aren't allowed~ and cause it to be left as tildes.
12 changes: 6 additions & 6 deletions test/cases/values.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0. Item *1*
0. *beginning* value
0. end *value*
0. *all*
0. *multiple* *values* with *some* intermediate text *sometimes*.
0. Spaces *aren't allowed* and cause it to be left as asterisks.
1. Item *1*
1. *beginning* value
1. end *value*
1. *all*
1. *multiple* *values* with *some* intermediate text *sometimes*.
1. Spaces *aren't allowed* and cause it to be left as asterisks.
16 changes: 8 additions & 8 deletions test/cases/variables.ecmarkdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
0. Item _1_
0. Let _x_ be awesome.
0. The foo_bar should not be variabled.
0. Neither should foo_bar baz_qux.
0. A _variable_with_underscores_ should be OK.
0. _variables_ can start
0. variables can _end_
0. Return _completion_.
1. Item _1_
1. Let _x_ be awesome.
1. The foo_bar should not be variabled.
1. Neither should foo_bar baz_qux.
1. A _variable_with_underscores_ should be OK.
1. _variables_ can start
1. variables can _end_
1. Return _completion_.

0 comments on commit 85daf3b

Please sign in to comment.