MarkdownReadmeReader.java
/*
* Copyright © 2024-2025 The CTAN Team and individual authors
*
* This file is distributed under the 3-clause BSD license.
* See file LICENSE for details.
*/
package org.ctan.site.services.texarchive.readme;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import org.ctan.markup.markdown.MarkdownRenderer;
/**
* The class <code>TextReadmeReader</code> contains the reader for markdown.
*
* @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
*/
public class MarkdownReadmeReader extends ReadmeReader {
/**
* This is the constructor for <code>MarkdownReadmeReader</code>.
*
* @param name the file name
*/
public MarkdownReadmeReader(String name) {
super(name);
}
/**
* {@inheritDoc}
*
* @see org.ctan.site.services.texarchive.readme.ReadmeReader#read(
* java.io.File)
*/
@Override
public String read(File file)
throws UnsupportedEncodingException,
IOException {
try (var reader = new FileReader(file, Charset.forName("UTF-8"))) {
return new MarkdownRenderer(reader, "").render();
}
}
}