Skip to content

Commit

Permalink
Support simpleNode (Horizontal rules + forced line breaks)
Browse files Browse the repository at this point in the history
  • Loading branch information
wattazoum committed Aug 7, 2016
1 parent a159499 commit 1d608da
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static int extensions() {
EXT |= Extensions.FENCED_CODE_BLOCKS;
EXT |= Extensions.TABLES;
EXT |= Extensions.STRIKETHROUGH;
// EXT |= Extensions.SMARTS; // Breaks link including a dash -

return EXT;
}
Expand Down Expand Up @@ -761,7 +762,28 @@ public void visit(ReferenceNode rn) {

@Override
public void visit(SimpleNode sn) {
notImplementedYet(sn);
switch (sn.getType()) {
case HRule:
_buffer.append("----\n");
break;
case Linebreak:
_buffer.append("\n");
break;
case Nbsp:
_buffer.append(" ");
break;
case Emdash:
_buffer.append("—");
break;
case Endash:
_buffer.append("–");
break;
case Ellipsis:
_buffer.append("…");
break;
default:
notImplementedYet(sn);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,19 @@ public void shouldSupportImgRefLink() throws IOException {
assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon-none\"!"));
}

@Test
public void shouldSupportSimpleNode() throws IOException {
InputStream stream = getClass().getResourceAsStream("simpleNodes.md");
InputStream inputStream = Site.processMarkdown(stream, "Test");
String converted = IOUtils.toString(inputStream);

assertThat("All forms of HRules should be supported", converted, containsString("----\n1\n----\n2\n----\n3\n----\n4\n----"));
/* only when Extensions.SMARTS is activated
assertThat(converted, containsString("…"));
assertThat(converted, containsString("–"));
assertThat(converted, containsString("—"));
*/
assertThat(converted, containsString("Forcing a line-break\nNext line in the list"));
assertThat(converted, containsString("      "));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Horizontal rules

----

1

****

2

***

3

* * *

4

- - - -

# Apostrophes

'I'm with single quotes'

"you're with double quotes"

I'll talk to him 'bout borrowin' one of his models.


# Ellipsis

Three dots `...` will be converted to ...

# Emdash

Use 3 dashes `---` for an em-dash --- .

# Range (endash)

"it's all in chapters 12--14"

# Line break

Forcing a line-break
Next line in the list

# Nbsp

      This will appear with six space characters in front of it.

0 comments on commit 1d608da

Please sign in to comment.