I am using liferay 6.1.1 and I want to put a text file with Markdown in the product and want to read the text from the file and needs to display the text in the terms_of_use.jsp The Markdown in the text file should be properly converted into the appropriate HTML and then displayed via terms_of_use.jsp
Please just any taglib to achieve the same.
Thank You
I read the text file content and stored the content in the session attribute in LoginUtil.java
String FilePath = PropsUtil.get("TextFilePath");
try{
String content = readTextFile(Path);
if(Validator.isNull(legalContent)){
_log.info("Empty text file");
session.setAttribute("Content", "No text to show");
} else{
session.setAttribute("Content", Content);
}
} catch(Exception e){
session.setAttribute("Content", e.getMessage());
_log.info("File Path either not exist or incorrect file path");
}
and fetching the session attribute in the terms_of_use.jsp as below:
<%
String content = request.getSession().getAttribute("Content").toString();
%>
<div><%= content %></div>
You can use any markdown conversion tool, e.g. already in your
readTextFile()method.I'm not sure if Liferay 6.1 already had its own Markdown conversion - you're on an awfully old version: It has been released in 2013, and as there's even a newer GA version in the 6.1 branch (also from 2013) odds are that there are issues (even security issues) with your version. I'd recommend you upgrade. Newer versions definitely have their own markdown processors - I'm not sure if they're available as a taglib, but either way: You can convert the text anywhere.