using CefSharp;
using CefSharp.WinForms;
namespace MintHTML
{
public partial class Form1 : Form
{
string markfile;
string htmlfile = "
Welcome to MintHTML
Open a markdown file and press \"Render preview\" to see the output here.
";
string csssuffix = @"
div{
font-family: monospace;
background-color: #F3F3F3;
border: solid;
border-width: 1px
}
";
string css;
// Custom functions
private void convert()
{
htmlfile = "";
using (StringReader reader = new StringReader(markfile))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("# "))
{
line = "" + line[1..] + "
";
}
else if (line.Contains("`"))
{
line = "" + line[1..^1] + "
";
}
else
{
line = line + "
";
}
htmlfile += line;
}
}
}
// Custom functions end
public Form1()
{
InitializeComponent();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("MintHTML is a simple Markdown converter and renderer made by SweeZero.", "About", MessageBoxButtons.OK);
}
private void button2_Click(object sender, EventArgs e)
{
Opener.ShowDialog();
textBox2.Text = Opener.FileName;
if (textBox2.Text.Length > 0)
{
markfile = File.ReadAllText(textBox2.Text);
convert();
chromiumWebBrowser1.LoadHtml(css + htmlfile);
}
}
private void Form1_Load(object sender, EventArgs e)
{
css = @"