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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<micrometer.version>1.13.10</micrometer.version>
<opensearch.version>3.3.0</opensearch.version>
<langchain4j.version>1.0.0</langchain4j.version>
<commonmark.version>0.22.0</commonmark.version>
</properties>
<dependencyManagement>

Expand Down Expand Up @@ -440,6 +441,21 @@
<artifactId>dot.txtmark</artifactId>
<version>0.14-SNAPSHOT_1</version>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>${commonmark.version}</version>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark-ext-gfm-tables</artifactId>
<version>${commonmark.version}</version>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark-ext-gfm-strikethrough</artifactId>
<version>${commonmark.version}</version>
</dependency>
<dependency>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.util-taglib</artifactId>
Expand Down
12 changes: 12 additions & 0 deletions dotCMS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,18 @@
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.txtmark</artifactId>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark</artifactId>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark-ext-gfm-tables</artifactId>
</dependency>
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark-ext-gfm-strikethrough</artifactId>
</dependency>
<dependency>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.util-taglib</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.dotcms.rendering.velocity.viewtools;
import com.dotcms.tiptap.TiptapMarkdown;
import com.dotcms.util.JsonUtil;
import com.dotmarketing.util.json.JSONObject;
import java.io.StringWriter;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -123,10 +126,32 @@ private String getFileContents(String path, boolean parseFirst) throws Throwable
}

}





/**
* parse a block of json to markdown
* @param parse
* @return
* @throws Throwable
*/
public String blockToMarkdown(String parse) throws Throwable {
if (parse == null || parse.isEmpty()) {
return "";
}
if (JsonUtil.isValidJSON(parse)) {
return TiptapMarkdown.toMarkdown(parse);
}
return parse;
}

/**
* parse a block of json to markdown
* @param parse
* @return
* @throws Throwable
*/
public String blockToMarkdown(JSONObject parse) throws Throwable {
return TiptapMarkdown.toMarkdown(parse);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dotcms.contenttype.transform.field.LegacyFieldTransformer;
import com.dotcms.rendering.velocity.viewtools.content.util.RenderableFactory;
import com.dotcms.tiptap.TiptapMarkdown;
import com.dotcms.util.JsonUtil;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
Expand Down Expand Up @@ -125,6 +126,17 @@ public String toHtml() {
return builder.toString();
}

/**
* Returns this Story Block's content as markdown. When the field holds raw HTML
* (no Tiptap JSON) it's returned unchanged.
*/
public String toMarkdown() {
if (this.jsonContFieldValue == null) {
return UtilMethods.isSet(this.htmlContFieldValue) ? this.htmlContFieldValue : StringPool.BLANK;
}
return TiptapMarkdown.toMarkdown(this.jsonContFieldValue);
}

@Override
public String toHtml(final String baseTemplatePath) {
final StringBuilder builder = new StringBuilder();
Expand Down
Loading
Loading