configuration rename htmlIgnoreNonClosedTags to htmlAllowNonClosedTags
This commit is contained in:
parent
d264671d40
commit
fddeb885a2
@ -46,6 +46,7 @@ listed in <Link name="commonmark-spec" /> are supported (including support for *
|
|||||||
* Lists (`ul`, `ol`)
|
* Lists (`ul`, `ol`)
|
||||||
* Images (`img` will require configured image loader)
|
* Images (`img` will require configured image loader)
|
||||||
* Blockquote (`blockquote`)
|
* Blockquote (`blockquote`)
|
||||||
|
* Heading (`h1`, `h2`, `h3`, `h4`, `h5`, `h6`)
|
||||||
* there is support to render any HTML tags, but it will require to create a special `TagHandler`,
|
* there is support to render any HTML tags, but it will require to create a special `TagHandler`,
|
||||||
more information can be found in [HTML section](/docs/html.md#custom-tag-handler)
|
more information can be found in [HTML section](/docs/html.md#custom-tag-handler)
|
||||||
* Task lists:
|
* Task lists:
|
||||||
|
@ -231,15 +231,15 @@ SpannableConfiguration.builder(context)
|
|||||||
If not provided explicitly, default `MarkwonHtmlRenderer` implementation will be used.
|
If not provided explicitly, default `MarkwonHtmlRenderer` implementation will be used.
|
||||||
It is documented [here](/docs/html.md#renderer)
|
It is documented [here](/docs/html.md#renderer)
|
||||||
|
|
||||||
### HTML ignore non-closed tags
|
### HTML allow non-closed tags
|
||||||
|
|
||||||
`htmlIgnoreNonClosedTags` option is used to control whether or not to
|
`htmlAllowNonClosedTags` option is used to control whether or not to
|
||||||
render non-closed HTML tags
|
render non-closed HTML tags
|
||||||
|
|
||||||
```java
|
```java
|
||||||
SpannableConfiguration.builder(context)
|
SpannableConfiguration.builder(context)
|
||||||
.htmlIgnoreNonClosedTags(boolean)
|
.htmlAllowNonClosedTags(boolean)
|
||||||
.build();
|
.build();
|
||||||
```
|
```
|
||||||
|
|
||||||
If not provided explicitly, default value `true` will be used (non-closed tags **won't** be rendered).
|
If not provided explicitly, default value `false` will be used (non-closed tags **won't** be rendered).
|
||||||
|
@ -143,13 +143,13 @@ but if you wish to get a bit closer to a web-browser experience, you can allow t
|
|||||||
|
|
||||||
```java{2}
|
```java{2}
|
||||||
SpannableConfiguration.builder(context)
|
SpannableConfiguration.builder(context)
|
||||||
.htmlIgnoreNonClosedTags(false)
|
.htmlAllowNonClosedTags(true)
|
||||||
.build();
|
.build();
|
||||||
```
|
```
|
||||||
|
|
||||||
:::warning Note
|
:::warning Note
|
||||||
If there is (for example) an `<i>` tag at the start of a document and it's not closed
|
If there is (for example) an `<i>` tag at the start of a document and it's not closed
|
||||||
and `Markwon` is configured to **not** ignore non-closed tags (`.htmlIgnoreNonClosedTags(false)`),
|
and `Markwon` is configured to **not** ignore non-closed tags (`.htmlAllowNonClosedTags(true)`),
|
||||||
it will make the whole document in italics
|
it will make the whole document in italics
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -195,6 +195,7 @@ Default instance have these tags _handled_:
|
|||||||
* `ol` (ordered list)
|
* `ol` (ordered list)
|
||||||
* `img` (image)
|
* `img` (image)
|
||||||
* `blockquote` (block quote)
|
* `blockquote` (block quote)
|
||||||
|
* `h{1-6}` (heading)
|
||||||
|
|
||||||
If you wish to _extend_ default handling (or override existing),
|
If you wish to _extend_ default handling (or override existing),
|
||||||
`#builderWithDefaults` factory method can be used:
|
`#builderWithDefaults` factory method can be used:
|
||||||
|
@ -37,7 +37,7 @@ public class SpannableConfiguration {
|
|||||||
private final boolean trimWhiteSpaceEnd; // @since 2.0.0
|
private final boolean trimWhiteSpaceEnd; // @since 2.0.0
|
||||||
private final MarkwonHtmlParser htmlParser; // @since 2.0.0
|
private final MarkwonHtmlParser htmlParser; // @since 2.0.0
|
||||||
private final MarkwonHtmlRenderer htmlRenderer; // @since 2.0.0
|
private final MarkwonHtmlRenderer htmlRenderer; // @since 2.0.0
|
||||||
private final boolean htmlIgnoreNonClosedTags; // @since 2.0.0
|
private final boolean htmlAllowNonClosedTags; // @since 2.0.0
|
||||||
|
|
||||||
private SpannableConfiguration(@NonNull Builder builder) {
|
private SpannableConfiguration(@NonNull Builder builder) {
|
||||||
this.theme = builder.theme;
|
this.theme = builder.theme;
|
||||||
@ -51,7 +51,7 @@ public class SpannableConfiguration {
|
|||||||
this.trimWhiteSpaceEnd = builder.trimWhiteSpaceEnd;
|
this.trimWhiteSpaceEnd = builder.trimWhiteSpaceEnd;
|
||||||
this.htmlParser = builder.htmlParser;
|
this.htmlParser = builder.htmlParser;
|
||||||
this.htmlRenderer = builder.htmlRenderer;
|
this.htmlRenderer = builder.htmlRenderer;
|
||||||
this.htmlIgnoreNonClosedTags = builder.htmlIgnoreNonClosedTags;
|
this.htmlAllowNonClosedTags = builder.htmlAllowNonClosedTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -124,8 +124,8 @@ public class SpannableConfiguration {
|
|||||||
/**
|
/**
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public boolean htmlIgnoreNonClosedTags() {
|
public boolean htmlAllowNonClosedTags() {
|
||||||
return htmlIgnoreNonClosedTags;
|
return htmlAllowNonClosedTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -143,7 +143,7 @@ public class SpannableConfiguration {
|
|||||||
private boolean trimWhiteSpaceEnd = true; // @since 2.0.0
|
private boolean trimWhiteSpaceEnd = true; // @since 2.0.0
|
||||||
private MarkwonHtmlParser htmlParser; // @since 2.0.0
|
private MarkwonHtmlParser htmlParser; // @since 2.0.0
|
||||||
private MarkwonHtmlRenderer htmlRenderer; // @since 2.0.0
|
private MarkwonHtmlRenderer htmlRenderer; // @since 2.0.0
|
||||||
private boolean htmlIgnoreNonClosedTags = true; // @since 2.0.0
|
private boolean htmlAllowNonClosedTags; // @since 2.0.0
|
||||||
|
|
||||||
Builder(@NonNull Context context) {
|
Builder(@NonNull Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@ -241,15 +241,15 @@ public class SpannableConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param htmlIgnoreNonClosedTags that indicates if non-closed html tags should be kept open.
|
* @param htmlAllowNonClosedTags that indicates if non-closed html tags should be rendered.
|
||||||
* If this argument is false then all non-closed HTML tags
|
* If this argument is true then all non-closed HTML tags
|
||||||
* will be closed at the end of a document. Otherwise they will
|
* will be closed at the end of a document. Otherwise they will
|
||||||
* be delivered non-closed {@code HtmlTag#isClosed()}
|
* be delivered non-closed {@code HtmlTag#isClosed()}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public Builder htmlIgnoreNonClosedTags(boolean htmlIgnoreNonClosedTags) {
|
public Builder htmlAllowNonClosedTags(boolean htmlAllowNonClosedTags) {
|
||||||
this.htmlIgnoreNonClosedTags = htmlIgnoreNonClosedTags;
|
this.htmlAllowNonClosedTags = htmlAllowNonClosedTags;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class MarkwonHtmlRendererImpl extends MarkwonHtmlRenderer {
|
|||||||
@NonNull MarkwonHtmlParser parser) {
|
@NonNull MarkwonHtmlParser parser) {
|
||||||
|
|
||||||
final int end;
|
final int end;
|
||||||
if (configuration.htmlIgnoreNonClosedTags()) {
|
if (!configuration.htmlAllowNonClosedTags()) {
|
||||||
end = HtmlTag.NO_END;
|
end = HtmlTag.NO_END;
|
||||||
} else {
|
} else {
|
||||||
end = builder.length();
|
end = builder.length();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user