Skip to content

Commit

Permalink
#7 Fix minor spacing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
melloc committed Mar 6, 2019
1 parent e363301 commit 35377ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var semantics = grammar.createSemantics().addOperation('toHTML', {

return ha + sep + hb;
},
blocks: function (blocks, _sp, _nl) {
blocks: function (_nl1, blocks, _nl2) {
return nodesToHTML(blocks, '\n');
},
tblock_paragraph: function (a, _nls) {
Expand Down
5 changes: 3 additions & 2 deletions lib/jira.ohm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
JIRA {
Document = blocks tblock?

blocks = (tblock (space* nl)+)*
blocks = blankl* (tblock blankl+)*

tblock
= block<empty>
Expand Down Expand Up @@ -107,9 +107,10 @@ JIRA {
urlend = urlexcl* ~urichar
urlexcl = "." | ")" | "!" | "," | "'"

space := " " | "\t"
space := " " | "\t" | "\u00a0"

nl (a newline) = "\r\n" | "\n" | "\r"
blankl = space* nl

blockStart = "{quote" | "{panel" | "{color" | "{noformat" | "{code"

Expand Down
8 changes: 8 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ test('Single Paragraph', function (t) {
t.equals(toHTML('hello world,\nand\ngood\nmorning!'),
'<p>hello world,<br />\nand<br />\ngood<br />\nmorning!</p>');

// Leading lines at start of document are okay
t.equals(toHTML('\nhello world'), '<p>hello world</p>');
t.equals(toHTML('\n\n\nhello world'), '<p>hello world</p>');

// Formatting at start of line that could be confused for bullets
t.equals(toHTML('hello world,\n*and*\n-good morning!-'),
'<p>hello world,<br />\n' +
Expand Down Expand Up @@ -142,6 +146,10 @@ test('Multiple Paragraphs', function (t) {
// Lines that are nothing but space can separate blocks
t.equals(toHTML('this is paragraph 1\n \nthis is paragraph 2'),
'<p>this is paragraph 1</p>\n<p>this is paragraph 2</p>');
t.equals(toHTML('this is paragraph 1\n\t\t\nthis is paragraph 2'),
'<p>this is paragraph 1</p>\n<p>this is paragraph 2</p>');
t.equals(toHTML('this is paragraph 1\n\u00a0\nthis is paragraph 2'),
'<p>this is paragraph 1</p>\n<p>this is paragraph 2</p>');

// Line breaks within a paragraph are preserved
t.equals(toHTML('this\nis\nparagraph\n1\n\nthis\nis\nparagraph\n2'),
Expand Down

0 comments on commit 35377ec

Please sign in to comment.