Skip to content

Commit

Permalink
#180 update dependencies
Browse files Browse the repository at this point in the history
#183 fix ordered list block
  • Loading branch information
Thorsten Marx committed Mar 12, 2024
1 parent b526891 commit c08532f
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 56 deletions.
2 changes: 1 addition & 1 deletion cms-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-api</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-content</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-extensions</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-filesystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-filesystem</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-git/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-git</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-markdown/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-markdown</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
* #L%
*/

import com.github.thmarx.cms.markdown.rules.block.BlockquoteBlockRule;
import com.github.thmarx.cms.markdown.rules.block.CodeBlockRule;
import com.github.thmarx.cms.markdown.rules.block.DefinitionListBlockRule;
import com.github.thmarx.cms.markdown.rules.block.HeadingBlockRule;
import com.github.thmarx.cms.markdown.rules.block.HorizontalRuleBlockRule;
import com.github.thmarx.cms.markdown.rules.block.ListBlockRule;
import com.github.thmarx.cms.markdown.rules.block.TableBlockRule;
import com.github.thmarx.cms.markdown.rules.block.TaskListBlockRule;
import com.github.thmarx.cms.markdown.rules.inline.HighlightInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.ImageInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.ImageLinkInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.ItalicInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.LinkInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.NewlineInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.StrikethroughInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.StrongInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.SubscriptInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.SuperscriptInlineRule;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -30,6 +48,32 @@
* @author t.marx
*/
public class Options {

public static Options all () {
Options options = new Options();
options.addInlineRule(new StrongInlineRule());
options.addInlineRule(new ItalicInlineRule());
options.addInlineRule(new NewlineInlineRule());
options.addInlineRule(new ImageLinkInlineRule());
options.addInlineRule(new LinkInlineRule());
options.addInlineRule(new ImageInlineRule());
options.addInlineRule(new StrikethroughInlineRule());
options.addInlineRule(new HighlightInlineRule());
options.addInlineRule(new SubscriptInlineRule());
options.addInlineRule(new SuperscriptInlineRule());

options.addBlockRule(new CodeBlockRule());
options.addBlockRule(new HeadingBlockRule());
options.addBlockRule(new TaskListBlockRule());
options.addBlockRule(new ListBlockRule());
options.addBlockRule(new HorizontalRuleBlockRule());
options.addBlockRule(new BlockquoteBlockRule());
options.addBlockRule(new TableBlockRule());
options.addBlockRule(new DefinitionListBlockRule());

return options;
}

public List<BlockElementRule> blockElementRules = new ArrayList<>();
public List<InlineElementRule> inlineElementRules = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Block next(String md) {
var listContent = matcher.group(0);
var items = listContent.split("\n");

var listItems = Stream.of(items).map(item -> item.replaceFirst("\\A^[0-9].*\\. ", "")).toList();
var listItems = Stream.of(items).map(item -> item.replaceFirst("\\A^[0-9]?\\. ", "")).toList();

return new ListBlock(matcher.start(), matcher.end(),
listItems, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.github.thmarx.cms.markdown.rules.block.BlockquoteBlockRule;
import com.github.thmarx.cms.markdown.rules.block.CodeBlockRule;
import com.github.thmarx.cms.markdown.rules.block.HeadingBlockRule;
import com.github.thmarx.cms.markdown.rules.block.HorizontalRuleBlockRule;
import com.github.thmarx.cms.markdown.rules.block.ListBlockRule;
import com.github.thmarx.cms.markdown.rules.inline.HighlightInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.ItalicInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.ImageInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.ImageLinkInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.LinkInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.StrongInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.NewlineInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.StrikethroughInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.SubscriptInlineRule;
import com.github.thmarx.cms.markdown.rules.inline.SuperscriptInlineRule;
import java.io.IOException;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -53,25 +38,7 @@ public class CMSMarkdownTest extends MarkdownTest {

@BeforeAll
public static void setup() {
Options options = new Options();
options.addInlineRule(new StrongInlineRule());
options.addInlineRule(new ItalicInlineRule());
options.addInlineRule(new NewlineInlineRule());
options.addInlineRule(new ImageLinkInlineRule());
options.addInlineRule(new LinkInlineRule());
options.addInlineRule(new ImageInlineRule());
options.addInlineRule(new StrikethroughInlineRule());
options.addInlineRule(new HighlightInlineRule());
options.addInlineRule(new SubscriptInlineRule());
options.addInlineRule(new SuperscriptInlineRule());

options.addBlockRule(new CodeBlockRule());
options.addBlockRule(new HeadingBlockRule());
options.addBlockRule(new ListBlockRule());
options.addBlockRule(new HorizontalRuleBlockRule());
options.addBlockRule(new BlockquoteBlockRule());

SUT = new CMSMarkdown(options);
SUT = new CMSMarkdown(Options.all());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.github.thmarx.cms.markdown;

/*-
* #%L
* cms-markdown
* %%
* Copyright (C) 2023 - 2024 Marx-Software
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.github.thmarx.cms.markdown.rules.block.ListBlockRule;
import java.io.IOException;
import java.util.List;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

/**
*
* @author t.marx
*/
public class ListIssuesTest extends MarkdownTest {

static CMSMarkdown SUT;

@BeforeAll
public static void setup() {
SUT = new CMSMarkdown(Options.all());
}

@Test
void test_dot_issue_183() throws IOException {

String md = "1. **first** sentence. second sentence.\n1. item 2";
String expected = """
<ol><li><strong>first</strong> sentence. second sentence.</li><li>item 2</li></ol>
""";

String html = SUT.render(md);


Assertions.assertThat(html).isEqualToIgnoringWhitespace(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,20 @@ void test_unordered_list_issue() {

Assertions.assertThat(next.render((content) -> content)).isEqualTo("<ul><li>ul item 1</li><li>ul item 2</li></ul>");
}

@Test
void test_dot_issue_183() {

String md = "1. first sentence. second sentence.\n1. item 2";

Block next = sut.next(md);

Assertions.assertThat(next)
.isNotNull()
.isInstanceOf(ListBlockRule.ListBlock.class)
.asInstanceOf(InstanceOfAssertFactories.type(ListBlockRule.ListBlock.class))
.hasFieldOrPropertyWithValue("items", List.of("first sentence. second sentence.", "item 2"));

Assertions.assertThat(next.render((content) -> content)).isEqualTo("<ol><li>first sentence. second sentence.</li><li>item 2</li></ol>");
}
}
2 changes: 1 addition & 1 deletion cms-media/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-media</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-sandbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-sandbox</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-server</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-template/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>cms-template</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules-framework/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms.module.framework</groupId>
<artifactId>module-framework</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>modules-api</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules-framework/manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms.module.framework</groupId>
<artifactId>module-framework</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>modules-manager</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<groupId>com.github.thmarx.cms.module.framework</groupId>
<artifactId>module-framework</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/example-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<artifactId>example-module</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
</parent>
<groupId>com.github.thmarx.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.thmarx.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>4.13.0</version>
<version>4.14.0</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<exec.mainClass>com.github.thmarx.cms.Startup</exec.mainClass>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<jetty.version>12.0.6</jetty.version>
<jetty.version>12.0.7</jetty.version>
</properties>
<modules>
<module>cms-api</module>
Expand Down Expand Up @@ -142,17 +142,17 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.22.1</version>
<version>2.23.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.22.1</version>
<version>2.23.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.22.1</version>
<version>2.23.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
Expand Down Expand Up @@ -235,7 +235,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.3.0</version>
<version>2.4.0</version>
<configuration>
<verbose>false</verbose>
<licenseName>gpl_v3</licenseName>
Expand Down

0 comments on commit c08532f

Please sign in to comment.