Skip to content

Commit

Permalink
Add test showing that the parser can now be properly extended, closes s…
Browse files Browse the repository at this point in the history
  • Loading branch information
sirthias committed Oct 4, 2011
1 parent 33c3c60 commit 07dda00
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/main/java/org/pegdown/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1243,10 +1243,6 @@ public String popAsString() {
return (String) pop();
}

public TextNode popAsTextNode() {
return (TextNode) pop();
}

public boolean ext(int extension) {
return (options & extension) > 0;
}
Expand Down
57 changes: 57 additions & 0 deletions src/test/java/org/pegdown/CustomParserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2010-2011 Mathias Doenitz
*
* Based on peg-markdown (C) 2008-2010 John MacFarlane
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.pegdown;

import org.parboiled.Parboiled;
import org.testng.annotations.Test;

import static org.pegdown.Extensions.*;

public class CustomParserTest extends AbstractTest {

public static class MyParser extends Parser {
public MyParser() {
super(Extensions.ALL);
}
}

private PegDownProcessor processor = new PegDownProcessor(Parboiled.createParser(MyParser.class));

@Override
public PegDownProcessor getProcessor() {
return processor;
}

@Test
public void testWithCustomParser() {
test("pegdown/Abbreviations");
test("pegdown/AttributeWithUnderScore");
test("pegdown/Autolinks");
test("pegdown/Bug_in_0.8.5.1");
test("pegdown/Bug_in_0.8.5.4");
test("pegdown/Bug_in_1.0.0");
test("pegdown/GFM_Fenced_Code_Blocks");
test("pegdown/Linebreaks");
test("pegdown/Parens_in_URL");
test("pegdown/Quoted Blockquote");
test("pegdown/Smartypants");
test("pegdown/Tables");
test("pegdown/Wikilinks");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.testng.annotations.Test;
import static org.pegdown.Extensions.*;

public class CustomPegDownTest extends AbstractTest {
public class PegDownTest extends AbstractTest {

/*private final PegDownProcessor processor = new PegDownProcessor(
Parboiled.createParser(Parser.class, Extensions.ALL,
Expand Down

0 comments on commit 07dda00

Please sign in to comment.