Moved html artifacts to corresponding packages

This commit is contained in:
Dimitry Ivanov 2018-08-17 16:47:11 +03:00
parent be484765da
commit 1bad514714
25 changed files with 72 additions and 69 deletions

View File

@ -18,6 +18,7 @@ dependencies {
} }
afterEvaluate { afterEvaluate {
generateDebugBuildConfig.enabled = false
generateReleaseBuildConfig.enabled = false generateReleaseBuildConfig.enabled = false
} }

View File

@ -1 +1 @@
<manifest package="ru.noties.markwon.html" /> <manifest package="ru.noties.markwon.html.api" />

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html; package ru.noties.markwon.html.api;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html; package ru.noties.markwon.html.api;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html; package ru.noties.markwon.html.api;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;

View File

@ -23,6 +23,7 @@ dependencies {
} }
afterEvaluate { afterEvaluate {
generateDebugBuildConfig.enabled = false
generateReleaseBuildConfig.enabled = false generateReleaseBuildConfig.enabled = false
} }

View File

@ -1 +1 @@
<manifest package="ru.noties.markwon.html" /> <manifest package="ru.noties.markwon.html.impl" />

View File

@ -1,9 +1,9 @@
package ru.noties.markwon.html; package ru.noties.markwon.html.impl;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import ru.noties.markwon.html.jsoup.parser.Token; import ru.noties.markwon.html.impl.jsoup.parser.Token;
/** /**
* This class will be used to append some text to output in order to * This class will be used to append some text to output in order to

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html; package ru.noties.markwon.html.impl;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -7,6 +7,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import ru.noties.markwon.html.api.HtmlTag;
abstract class HtmlTagImpl implements HtmlTag { abstract class HtmlTagImpl implements HtmlTag {
private static final int NO_VALUE = -1; private static final int NO_VALUE = -1;

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html; package ru.noties.markwon.html.impl;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -14,16 +14,15 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import ru.noties.markwon.html.HtmlTag.Block; import ru.noties.markwon.html.api.HtmlTag.Block;
import ru.noties.markwon.html.HtmlTag.Inline; import ru.noties.markwon.html.api.HtmlTag.Inline;
import ru.noties.markwon.html.HtmlTagImpl.BlockImpl; import ru.noties.markwon.html.api.MarkwonHtmlParser;
import ru.noties.markwon.html.HtmlTagImpl.InlineImpl; import ru.noties.markwon.html.impl.jsoup.nodes.Attribute;
import ru.noties.markwon.html.jsoup.nodes.Attribute; import ru.noties.markwon.html.impl.jsoup.nodes.Attributes;
import ru.noties.markwon.html.jsoup.nodes.Attributes; import ru.noties.markwon.html.impl.jsoup.parser.CharacterReader;
import ru.noties.markwon.html.jsoup.parser.CharacterReader; import ru.noties.markwon.html.impl.jsoup.parser.ParseErrorList;
import ru.noties.markwon.html.jsoup.parser.ParseErrorList; import ru.noties.markwon.html.impl.jsoup.parser.Token;
import ru.noties.markwon.html.jsoup.parser.Token; import ru.noties.markwon.html.impl.jsoup.parser.Tokeniser;
import ru.noties.markwon.html.jsoup.parser.Tokeniser;
public class MarkwonHtmlParserImpl extends MarkwonHtmlParser { public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
@ -108,9 +107,9 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
private final HtmlEmptyTagReplacement emptyTagReplacement; private final HtmlEmptyTagReplacement emptyTagReplacement;
private final List<InlineImpl> inlineTags = new ArrayList<>(0); private final List<HtmlTagImpl.InlineImpl> inlineTags = new ArrayList<>(0);
private BlockImpl currentBlock = BlockImpl.root(); private HtmlTagImpl.BlockImpl currentBlock = HtmlTagImpl.BlockImpl.root();
MarkwonHtmlParserImpl(@NonNull HtmlEmptyTagReplacement replacement) { MarkwonHtmlParserImpl(@NonNull HtmlEmptyTagReplacement replacement) {
this.emptyTagReplacement = replacement; this.emptyTagReplacement = replacement;
@ -174,7 +173,7 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
@Override @Override
public void flushInlineTags(int documentLength, @NonNull FlushAction<Inline> action) { public void flushInlineTags(int documentLength, @NonNull FlushAction<Inline> action) {
if (inlineTags.size() > 0) { if (inlineTags.size() > 0) {
for (InlineImpl inline : inlineTags) { for (HtmlTagImpl.InlineImpl inline : inlineTags) {
inline.closeAt(documentLength); inline.closeAt(documentLength);
} }
//noinspection unchecked //noinspection unchecked
@ -186,7 +185,7 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
@Override @Override
public void flushBlockTags(int documentLength, @NonNull FlushAction<Block> action) { public void flushBlockTags(int documentLength, @NonNull FlushAction<Block> action) {
BlockImpl block = currentBlock; HtmlTagImpl.BlockImpl block = currentBlock;
while (!block.isRoot()) { while (!block.isRoot()) {
block = block.parent; block = block.parent;
} }
@ -198,13 +197,13 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
action.apply(children); action.apply(children);
} }
currentBlock = BlockImpl.root(); currentBlock = HtmlTagImpl.BlockImpl.root();
} }
@Override @Override
public void reset() { public void reset() {
inlineTags.clear(); inlineTags.clear();
currentBlock = BlockImpl.root(); currentBlock = HtmlTagImpl.BlockImpl.root();
} }
@ -214,7 +213,7 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
final String name = startTag.normalName; final String name = startTag.normalName;
final InlineImpl inline = new InlineImpl(name, output.length(), extractAttributes(startTag)); final HtmlTagImpl.InlineImpl inline = new HtmlTagImpl.InlineImpl(name, output.length(), extractAttributes(startTag));
if (isVoidTag(name) if (isVoidTag(name)
|| startTag.selfClosing) { || startTag.selfClosing) {
@ -239,7 +238,7 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
@NonNull Token.EndTag endTag) { @NonNull Token.EndTag endTag) {
// try to find it, if none found -> ignore // try to find it, if none found -> ignore
final InlineImpl openInline = findOpenInlineTag(endTag.normalName); final HtmlTagImpl.InlineImpl openInline = findOpenInlineTag(endTag.normalName);
if (openInline != null) { if (openInline != null) {
// close open inline tag // close open inline tag
openInline.closeAt(output.length()); openInline.closeAt(output.length());
@ -276,7 +275,7 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
final int start = output.length(); final int start = output.length();
final BlockImpl block = BlockImpl.create(name, start, extractAttributes(startTag), currentBlock); final HtmlTagImpl.BlockImpl block = HtmlTagImpl.BlockImpl.create(name, start, extractAttributes(startTag), currentBlock);
final boolean isVoid = isVoidTag(name) || startTag.selfClosing; final boolean isVoid = isVoidTag(name) || startTag.selfClosing;
if (isVoid) { if (isVoid) {
@ -303,7 +302,7 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
final String name = endTag.normalName; final String name = endTag.normalName;
final BlockImpl block = findOpenBlockTag(endTag.normalName); final HtmlTagImpl.BlockImpl block = findOpenBlockTag(endTag.normalName);
if (block != null) { if (block != null) {
block.closeAt(output.length()); block.closeAt(output.length());
@ -334,8 +333,8 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
append(output, character.getData()); append(output, character.getData());
} }
protected void appendBlockChild(@NonNull BlockImpl parent, @NonNull BlockImpl child) { protected void appendBlockChild(@NonNull HtmlTagImpl.BlockImpl parent, @NonNull HtmlTagImpl.BlockImpl child) {
List<BlockImpl> children = parent.children; List<HtmlTagImpl.BlockImpl> children = parent.children;
if (children == null) { if (children == null) {
children = new ArrayList<>(2); children = new ArrayList<>(2);
parent.children = children; parent.children = children;
@ -344,9 +343,9 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
} }
@Nullable @Nullable
protected InlineImpl findOpenInlineTag(@NonNull String name) { protected HtmlTagImpl.InlineImpl findOpenInlineTag(@NonNull String name) {
InlineImpl inline; HtmlTagImpl.InlineImpl inline;
for (int i = inlineTags.size() - 1; i > -1; i--) { for (int i = inlineTags.size() - 1; i > -1; i--) {
inline = inlineTags.get(i); inline = inlineTags.get(i);
@ -360,9 +359,9 @@ public class MarkwonHtmlParserImpl extends MarkwonHtmlParser {
} }
@Nullable @Nullable
protected BlockImpl findOpenBlockTag(@NonNull String name) { protected HtmlTagImpl.BlockImpl findOpenBlockTag(@NonNull String name) {
BlockImpl blockTag = currentBlock; HtmlTagImpl.BlockImpl blockTag = currentBlock;
while (blockTag != null while (blockTag != null
&& !name.equals(blockTag.name) && !blockTag.isClosed()) { && !name.equals(blockTag.name) && !blockTag.isClosed()) {

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup; package ru.noties.markwon.html.impl.jsoup;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.helper; package ru.noties.markwon.html.impl.jsoup.helper;
import java.util.Locale; import java.util.Locale;

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.helper; package ru.noties.markwon.html.impl.jsoup.helper;
/** /**
* Simple validation methods. Designed for jsoup internal use * Simple validation methods. Designed for jsoup internal use

View File

@ -1,8 +1,8 @@
package ru.noties.markwon.html.jsoup.nodes; package ru.noties.markwon.html.impl.jsoup.nodes;
import java.util.Map; import java.util.Map;
import ru.noties.markwon.html.jsoup.helper.Validate; import ru.noties.markwon.html.impl.jsoup.helper.Validate;
/** /**
A single key + value attribute. (Only used for presentation.) A single key + value attribute. (Only used for presentation.)

View File

@ -1,18 +1,14 @@
package ru.noties.markwon.html.jsoup.nodes; package ru.noties.markwon.html.impl.jsoup.nodes;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import ru.noties.markwon.html.jsoup.helper.Validate; import ru.noties.markwon.html.impl.jsoup.helper.Validate;
import static ru.noties.markwon.html.jsoup.helper.Normalizer.lowerCase; import static ru.noties.markwon.html.impl.jsoup.helper.Normalizer.lowerCase;
/** /**
* The attributes of an Element. * The attributes of an Element.

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.nodes; package ru.noties.markwon.html.impl.jsoup.nodes;
/** /**
* A {@code <!DOCTYPE>} node. * A {@code <!DOCTYPE>} node.

View File

@ -1,14 +1,14 @@
package ru.noties.markwon.html.jsoup.nodes; package ru.noties.markwon.html.impl.jsoup.nodes;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import ru.noties.markwon.html.jsoup.helper.Validate; import ru.noties.markwon.html.impl.jsoup.helper.Validate;
import ru.noties.markwon.html.jsoup.parser.CharacterReader; import ru.noties.markwon.html.impl.jsoup.parser.CharacterReader;
import static ru.noties.markwon.html.jsoup.nodes.Entities.EscapeMode.base; import static ru.noties.markwon.html.impl.jsoup.nodes.Entities.EscapeMode.base;
import static ru.noties.markwon.html.jsoup.nodes.Entities.EscapeMode.extended; import static ru.noties.markwon.html.impl.jsoup.nodes.Entities.EscapeMode.extended;
/** /**
* HTML entities, and escape routines. Source: <a href="http://www.w3.org/TR/html5/named-character-references.html#named-character-references">W3C * HTML entities, and escape routines. Source: <a href="http://www.w3.org/TR/html5/named-character-references.html#named-character-references">W3C

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.nodes; package ru.noties.markwon.html.impl.jsoup.nodes;
/** /**
* Holds packed data that represents Entity name=value pairs. Parsed by Entities, created by BuildEntities. * Holds packed data that represents Entity name=value pairs. Parsed by Entities, created by BuildEntities.

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.parser; package ru.noties.markwon.html.impl.jsoup.parser;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
@ -6,8 +6,8 @@ import java.io.StringReader;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import ru.noties.markwon.html.jsoup.UncheckedIOException; import ru.noties.markwon.html.impl.jsoup.UncheckedIOException;
import ru.noties.markwon.html.jsoup.helper.Validate; import ru.noties.markwon.html.impl.jsoup.helper.Validate;
/** /**
CharacterReader consumes tokens off a string. Used internally by jsoup. API subject to changes. CharacterReader consumes tokens off a string. Used internally by jsoup. API subject to changes.

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.parser; package ru.noties.markwon.html.impl.jsoup.parser;
/** /**
* A Parse Error records an error in the input HTML that occurs in either the tokenisation or the tree building phase. * A Parse Error records an error in the input HTML that occurs in either the tokenisation or the tree building phase.

View File

@ -1,4 +1,4 @@
package ru.noties.markwon.html.jsoup.parser; package ru.noties.markwon.html.impl.jsoup.parser;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,11 +1,11 @@
package ru.noties.markwon.html.jsoup.parser; package ru.noties.markwon.html.impl.jsoup.parser;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import ru.noties.markwon.html.jsoup.helper.Validate; import ru.noties.markwon.html.impl.jsoup.helper.Validate;
import ru.noties.markwon.html.jsoup.nodes.Attributes; import ru.noties.markwon.html.impl.jsoup.nodes.Attributes;
import static ru.noties.markwon.html.jsoup.helper.Normalizer.lowerCase; import static ru.noties.markwon.html.impl.jsoup.helper.Normalizer.lowerCase;
/** /**
* Parse tokens for the Tokeniser. * Parse tokens for the Tokeniser.

View File

@ -1,9 +1,9 @@
package ru.noties.markwon.html.jsoup.parser; package ru.noties.markwon.html.impl.jsoup.parser;
import java.util.Arrays; import java.util.Arrays;
import ru.noties.markwon.html.jsoup.helper.Validate; import ru.noties.markwon.html.impl.jsoup.helper.Validate;
import ru.noties.markwon.html.jsoup.nodes.Entities; import ru.noties.markwon.html.impl.jsoup.nodes.Entities;
/** /**
* Readers the input stream into tokens. * Readers the input stream into tokens.

View File

@ -1,6 +1,6 @@
package ru.noties.markwon.html.jsoup.parser; package ru.noties.markwon.html.impl.jsoup.parser;
import ru.noties.markwon.html.jsoup.nodes.DocumentType; import ru.noties.markwon.html.impl.jsoup.nodes.DocumentType;
/** /**
* States and transition activations for the Tokeniser. * States and transition activations for the Tokeniser.

View File

@ -14,7 +14,11 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import ru.noties.markwon.html.jsoup.parser.Token; import ru.noties.markwon.html.api.HtmlTag;
import ru.noties.markwon.html.api.MarkwonHtmlParser;
import ru.noties.markwon.html.impl.HtmlEmptyTagReplacement;
import ru.noties.markwon.html.impl.MarkwonHtmlParserImpl;
import ru.noties.markwon.html.impl.jsoup.parser.Token;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;