Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support simpleNode (Horizontal rules + forced line breaks) #120

Merged
merged 1 commit into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.