Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ optimization of implementation classes. Changes are detailed in
* For Versions 0.62.2 or below, Java 8 or above, Java 9+ compatible. For Versions 0.64.0 or
above, Java 11 or above.
* The project is on Maven: `com.vladsch.flexmark`
* The core has no dependencies other than `org.jetbrains:annotations:24.0.1`. For extensions, see
* The core has no dependencies other than `org.jspecify:jspecify:1.0.0`. For extensions, see
extension description below.

The API is still evolving to accommodate new extensions and functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@
import com.vladsch.flexmark.util.misc.Pair;
import com.vladsch.flexmark.util.sequence.BasedSequence;
import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.*;

import static com.vladsch.flexmark.formatter.Formatter.RESTORE_TRACKED_SPACES;

public abstract class FormatterSpecTest extends FormatterTranslationSpecTestBase {
public FormatterSpecTest(@NotNull SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
public FormatterSpecTest(SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
super(example, optionMap, defaultOptions);
}

@Override
public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) {
public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) {
DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions);

return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), Formatter.builder(combinedOptions).build(), true) {
@NotNull List<TrackedOffset> trackedOffsets = Collections.emptyList();
List<TrackedOffset> trackedOffsets = Collections.emptyList();
BasedSequence trackedSequence;
BasedSequence originalSequence;

Expand Down Expand Up @@ -64,7 +63,7 @@ public void parse(CharSequence input) {
}

@Override
protected @NotNull String renderHtml() {
protected String renderHtml() {
if (trackedOffsets.isEmpty() && !SHOW_LINE_RANGES.get(myOptions)) {
return getRenderer().render(getDocument());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import com.vladsch.flexmark.util.data.SharedDataKeys;
import com.vladsch.flexmark.util.format.options.*;
import com.vladsch.flexmark.util.sequence.SequenceUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -155,7 +154,7 @@ static DataHolder marginOption(@Nullable Integer params) {
return new MutableDataSet().set(Formatter.RIGHT_MARGIN, value);
}

public FormatterTranslationSpecTestBase(@NotNull SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
public FormatterTranslationSpecTestBase(SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import com.vladsch.flexmark.test.util.spec.SpecExample;
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -23,7 +22,7 @@ public abstract class RendererSpecTest extends ComboSpecTestCase {
static {
optionsMap.put("src-pos", new MutableDataSet().set(HtmlRenderer.SOURCE_POSITION_ATTRIBUTE, "md-pos"));
}
public RendererSpecTest(@NotNull SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
public RendererSpecTest(SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions));
}

Expand All @@ -35,7 +34,7 @@ protected boolean wantExampleInfo() {
}

@Override
final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) {
final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) {
DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions);
return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), HtmlRenderer.builder(combinedOptions).build(), wantExampleInfo());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.DataKey;
import com.vladsch.flexmark.util.data.MutableDataSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -42,7 +41,7 @@ public abstract class TranslationFormatterSpecTest extends FormatterTranslationS
optionsMap.put("details", new MutableDataSet().set(DETAILS, true));
optionsMap.put("ast-details", new MutableDataSet().set(AST_DETAILS, true));
}
public TranslationFormatterSpecTest(@NotNull SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
public TranslationFormatterSpecTest(SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions));
}

Expand All @@ -55,11 +54,11 @@ private IRender getRenderer(@Nullable DataHolder OPTIONS) {
}

@Override
final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) {
final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) {
DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions);
return new FlexmarkSpecExampleRenderer(example, combinedOptions, getParser(combinedOptions), getRenderer(combinedOptions), true) {
@Override
protected @NotNull String renderAst() {
protected String renderAst() {
TranslationFormatter translationFormatter = (TranslationFormatter) getRenderer();
if (translationFormatter.isShowIntermediateAst()) {
return translationFormatter.getAst();
Expand Down Expand Up @@ -116,7 +115,6 @@ public boolean isShowIntermediateAst() {
return myShowIntermediateAst;
}

@NotNull
public String getAst() {
return myAst == null ? "" : myAst;
}
Expand All @@ -128,7 +126,7 @@ public DataHolder getOptions() {
}

@Override
public void render(@NotNull Node node, @NotNull Appendable output) {
public void render(Node node, Appendable output) {
Document document = (Document) node;

TranslationHandler handler = myFormatter.getTranslationHandler();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
@NullMarked
package com.vladsch.flexmark.core.test.util;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
import com.vladsch.flexmark.test.util.spec.SpecExample;
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;
import org.jetbrains.annotations.NotNull;
import org.junit.runners.Parameterized;

import java.util.List;

public class ComboCoreFormatterNoBlankLinesSpecTest extends ComboCoreFormatterSpecTestBase {
final private static String SPEC_RESOURCE = "/core_formatter_no_blanklines_spec.md";
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final private static DataHolder OPTIONS = new MutableDataSet()
.set(Parser.BLANK_LINES_IN_AST, false)
.toImmutable();

public ComboCoreFormatterNoBlankLinesSpecTest(@NotNull SpecExample example) {
public ComboCoreFormatterNoBlankLinesSpecTest(SpecExample example) {
super(example, null, OPTIONS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import com.vladsch.flexmark.test.util.spec.ResourceLocation;
import com.vladsch.flexmark.test.util.spec.SpecExample;
import org.jetbrains.annotations.NotNull;
import org.junit.runners.Parameterized;

import java.util.List;

public class ComboCoreFormatterSpecTest extends ComboCoreFormatterSpecTestBase {
final private static String SPEC_RESOURCE = "/core_formatter_spec.md";
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);

public ComboCoreFormatterSpecTest(@NotNull SpecExample example) {
public ComboCoreFormatterSpecTest(SpecExample example) {
super(example, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import com.vladsch.flexmark.test.util.ComboSpecTestCase;
import com.vladsch.flexmark.test.util.spec.SpecExample;
import com.vladsch.flexmark.util.data.DataHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -16,7 +15,7 @@ public abstract class ComboCoreFormatterSpecTestBase extends FormatterSpecTest {
// optionsMap.put("atx-space-as-is", new MutableDataSet().set(Formatter.SPACE_AFTER_ATX_MARKER, DiscretionaryText.AS_IS));
// }

public ComboCoreFormatterSpecTestBase(@NotNull SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
public ComboCoreFormatterSpecTestBase(SpecExample example, @Nullable Map<String, ? extends DataHolder> optionMap, @Nullable DataHolder... defaultOptions) {
super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), defaultOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;
import com.vladsch.flexmark.util.format.options.*;
import org.jetbrains.annotations.NotNull;
import org.junit.runners.Parameterized;

import java.util.List;
import java.util.Map;

public class ComboCoreTranslationFormatterSpecTest extends TranslationFormatterSpecTest {
final private static String SPEC_RESOURCE = "/core_translation_formatter_spec.md";
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);

final private static Map<String, DataHolder> optionsMap = placementAndSortOptions(
Parser.REFERENCES_KEEP,
Expand Down Expand Up @@ -61,7 +60,7 @@ public class ComboCoreTranslationFormatterSpecTest extends TranslationFormatterS
optionsMap.put("explicit-links-at-start", new MutableDataSet().set(Formatter.KEEP_EXPLICIT_LINKS_AT_START, true));
optionsMap.put("remove-empty-items", new MutableDataSet().set(Formatter.LIST_REMOVE_EMPTY_ITEMS, true));
}
public ComboCoreTranslationFormatterSpecTest(@NotNull SpecExample example) {
public ComboCoreTranslationFormatterSpecTest(SpecExample example) {
super(example, optionsMap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.MutableDataSet;
import com.vladsch.flexmark.util.data.SharedDataKeys;
import org.jetbrains.annotations.NotNull;
import org.junit.runners.Parameterized;

import java.util.List;

public class ComboCoreWrappingSpecTest extends ComboCoreFormatterSpecTestBase {
final private static String SPEC_RESOURCE = "/core_wrapping_spec.md";
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);

final private static DataHolder OPTIONS = new MutableDataSet()
.set(SharedDataKeys.RUNNING_TESTS, false) // Set to true to get stdout printout of intermediate wrapping information
.toImmutable();

public ComboCoreWrappingSpecTest(@NotNull SpecExample example) {
public ComboCoreWrappingSpecTest(SpecExample example) {
super(example, null, OPTIONS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import com.vladsch.flexmark.util.misc.Pair;
import com.vladsch.flexmark.util.sequence.BasedSequence;
import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.junit.runners.Parameterized;

import java.io.IOException;
Expand All @@ -32,7 +31,7 @@

public class ComboParagraphFormatterSpecTest extends ComboCoreFormatterSpecTestBase {
final private static String SPEC_RESOURCE = "/core_paragraph_formatter_spec.md";
final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);
final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE);

final public static DataKey<Integer> FIRST_WIDTH_DELTA = new DataKey<>("FIRST_WIDTH_DELTA", 0);

Expand All @@ -44,7 +43,7 @@ public class ComboParagraphFormatterSpecTest extends ComboCoreFormatterSpecTestB
static {
optionsMap.put("first-width-delta", new MutableDataSet().set(TestUtils.CUSTOM_OPTION, (option, params) -> TestUtils.customIntOption(option, params, ComboParagraphFormatterSpecTest::firstWidthDeltaOption)));
}
public ComboParagraphFormatterSpecTest(@NotNull SpecExample example) {
public ComboParagraphFormatterSpecTest(SpecExample example) {
super(example, optionsMap, OPTIONS);
}

Expand All @@ -59,11 +58,10 @@ public static List<Object[]> data() {
}

static class ParagraphTextNode extends Node {
public ParagraphTextNode(@NotNull BasedSequence chars) {
public ParagraphTextNode(BasedSequence chars) {
super(chars);
}

@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
Expand All @@ -79,7 +77,7 @@ public ParagraphParser(DataHolder options) {
}

@Override
public @NotNull Node parse(@NotNull BasedSequence input) {
public Node parse(BasedSequence input) {
return new ParagraphTextNode(input);
}
}
Expand All @@ -97,7 +95,7 @@ public ParagraphFormatter(DataHolder options) {
final static String BANNER_RESULT = TestUtils.bannerText("Result");

@Override
public void render(@NotNull Node document, @NotNull Appendable output) {
public void render(Node document, Appendable output) {
BasedSequence input = document.getChars();
StringBuilder out = new StringBuilder();
Boolean inTest = SharedDataKeys.RUNNING_TESTS.get(getOptions());
Expand Down Expand Up @@ -186,12 +184,12 @@ public void render(@NotNull Node document, @NotNull Appendable output) {
}

@Override
final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) {
final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) {
DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions);
return new FlexmarkSpecExampleRenderer(example, combinedOptions, new ParagraphParser(combinedOptions), new ParagraphFormatter(combinedOptions), true) {

@Override
protected @NotNull String renderHtml() {
protected String renderHtml() {
if (SharedDataKeys.RUNNING_TESTS.get(myOptions)) {
System.out.printf("%s:%d%n", myExample.getSection(), myExample.getExampleNumber());
}
Expand All @@ -200,7 +198,7 @@ public void render(@NotNull Node document, @NotNull Appendable output) {
}

@Override
protected @NotNull String renderAst() {
protected String renderAst() {
return TestUtils.ast(getDocument());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.vladsch.flexmark.util.html.Attributes;
import com.vladsch.flexmark.util.html.MutableAttributes;
import com.vladsch.flexmark.util.sequence.BasedSequence;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -63,9 +62,8 @@ private static class TestNodeFactory extends NodePostProcessorFactory {
addNodes(Paragraph.class);
}

@NotNull
@Override
public NodePostProcessor apply(@NotNull Document document) {
public NodePostProcessor apply(Document document) {
return new TestNodePostProcessor();
}
}
Expand All @@ -75,7 +73,7 @@ public static NodePostProcessorFactory Factory(DataHolder options) {
}

@Override
public void process(@NotNull NodeTracker state, @NotNull Node node) {
public void process(NodeTracker state, Node node) {
BasedSequence paragraphText = BasedSequence.NULL;
if (node instanceof Paragraph) { // [foo](http://example.com)
MutableAttributes attributes = new MutableAttributes();
Expand All @@ -94,12 +92,12 @@ static class TestNodePostProcessorExtension implements Parser.ParserExtension, H
private TestNodePostProcessorExtension() { }

@Override
public void rendererOptions(@NotNull MutableDataHolder options) {
public void rendererOptions(MutableDataHolder options) {
// add any configuration settings to options you want to apply to everything, here
}

@Override
public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) {
public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) {
htmlRendererBuilder.attributeProviderFactory(EmbeddedAttributeProvider.Factory);
}

Expand Down
Loading