Skip to content

Commit

Permalink
Extensions readme (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmarx authored Jan 6, 2024
1 parent 98addb9 commit cb291bf
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,76 @@ options.getSafelist().removeProtocols("img", "src", "http", "https");

String html2 = Marked.marked("![alt text](/img/some-image.png \"title\")", options);
// => <p><img src="/img/some-image.png" alt="alt text" title="title"></p>
```

## Extensions

Markedj can be extended by implementing [custom extensions](https://github.com/gitbucket/markedj/blob/master/src/main/java/io/github/gitbucket/markedj/extension/Extension.java).
Extensions can be used by adding them to the options.

```java
Options options = new Options();
options.addExtension(new NotificationExtension());
String html = Marked.marked("! This is an info message", options);
// => <div class="notification_info"><p>This is an info message</p></div>
```

### Notification extension

The notification extension helps you to add information messages to your markdown content.
Keep in mind, you still need the CSS to style the messages as desired.

#### Info message
```text
! This is an info message
```
```html
<div class="notification_info">
<p>This is an info message</p>
</div>
```

#### Success message
```text
!v This is a success message
```
```html
<div class="notification_success">
<p>This is a success message</p>
</div>
```

#### Warning message
```text
!! This is a warning message
```
```html
<div class="notification_warning">
<p>This is a warning message</p>
</div>
```

#### Error message
```text
!x This is an error message
```
```html
<div class="notification_error">
<p>This is an error message</p>
</div>
```

#### Multiline notifications
Notifications can span multiple lines.

```text
! This is an info message
! That spans over several lines
```
```html
<div class="notification_info">
<p>This is an info message
That spans over several lines</p>
</div>

```

0 comments on commit cb291bf

Please sign in to comment.