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

Extensions readme #50

Merged
merged 4 commits into from
Jan 6, 2024
Merged
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
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>

```