Skip to content

Commit

Permalink
Inline-only parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
AshurAxelR committed Apr 7, 2019
1 parent 1e16d44 commit fe7716f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ JParsedown parsedown = new JParsedown();
System.out.println(parsedown.text("Hello _Parsedown_!")); // prints: <p>Hello <em>Parsedown</em>!</p>
```

You can also parse inline markdown only:

```java
System.out.println(parsedown.line("Hello _Parsedown_!")); // prints: Hello <em>Parsedown</em>!
```

### Security

See [Parsedown Security](https://github.com/erusev/parsedown#security) page.
Expand All @@ -42,10 +48,10 @@ See [Parsedown Security](https://github.com/erusev/parsedown#security) page.
### Header IDs

Github automatically generates anchor IDs for each header in Markdown file to make it
easier to reference individual sections and create contents. JParsedown will attempt to generate
easier to reference individual sections and create the table of contents. JParsedown attempts to generate
the same IDs, so the itra-page links in rendered HTML page still work like on Github.

For example, `## Header IDs` will create the following HTML:
For example, `## Header IDs` creates the following HTML:

```
<h2 id="header-ids">Header IDs</h2>
Expand Down
6 changes: 5 additions & 1 deletion src/com/xrbpowered/jparsedown/JParsedown.java
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,10 @@ protected Inline[] getInlineTypes(char marker) {

protected Pattern inlineMarkerList = Pattern.compile("[!\\*_&\\[:<`~\\\\]");

public String line(String line) {
return elements(lineElements(line, null));
}

protected LinkedList<Element> lineElements(String text, HashSet<Class<?>> nonNestables) {
text = text.replaceAll("\\r\\n?", "\n");
LinkedList<Element> elements = new LinkedList<>();
Expand Down Expand Up @@ -1497,5 +1501,5 @@ public static int startSpan(String s, char c) {
while(i<len && s.charAt(i)==c) i++;
return i;
}

}

0 comments on commit fe7716f

Please sign in to comment.