tweaked markdown converter

This commit is contained in:
Swee 2024-05-15 16:20:04 -07:00
parent 1b1a62845a
commit f399b92bed
2 changed files with 22 additions and 13 deletions

5
Form1.Designer.cs generated
View file

@ -75,15 +75,16 @@
//
openDevToolsToolStripMenuItem.Enabled = false;
openDevToolsToolStripMenuItem.Name = "openDevToolsToolStripMenuItem";
openDevToolsToolStripMenuItem.Size = new Size(154, 22);
openDevToolsToolStripMenuItem.Size = new Size(180, 22);
openDevToolsToolStripMenuItem.Text = "Open DevTools";
openDevToolsToolStripMenuItem.Click += openDevToolsToolStripMenuItem_Click_1;
//
// exitToolStripMenuItem
//
exitToolStripMenuItem.Name = "exitToolStripMenuItem";
exitToolStripMenuItem.Size = new Size(154, 22);
exitToolStripMenuItem.Size = new Size(180, 22);
exitToolStripMenuItem.Text = "Exit";
exitToolStripMenuItem.Click += exitToolStripMenuItem_Click;
//
// helpToolStripMenuItem
//

View file

@ -1,5 +1,6 @@
using CefSharp;
using CefSharp.WinForms;
using System.Linq.Expressions;
namespace MintHTML
{
@ -27,53 +28,55 @@ border-width: 1px
string line;
while ((line = reader.ReadLine()) != null)
{
try
{
// Header 1
if (line[0..1] == "# ")
if (line[1..2] == "# ")
{
line = "<h1>" + line[1..] + "</h1>";
}
// Header 2
else if (line[0..2] == "## ")
else if (line[1..3] == "## ")
{
line = "<h2>" + line[1..] + "</h2>";
}
// Header 3
else if (line[0..3] == "### ")
else if (line[1..4] == "### ")
{
line = "<h3>" + line[1..] + "</h3>";
}
// Header 4
else if (line[0..4] == "#### ")
else if (line[1..5] == "#### ")
{
line = "<h4>" + line[1..] + "</h4>";
}
// Header 5
else if (line[0..5] == "##### ")
else if (line[1..6] == "##### ")
{
line = "<h5>" + line[1..] + "</h5>";
}
// Header 6
else if (line[0..6] == "###### ")
else if (line[1..7] == "###### ")
{
line = "<h6>" + line[1..] + "</h6>";
}
// Bullet point
else if (line[0..1] == "* ")
else if (line[1..2] == "* ")
{
line = "<li>" + line[1..] + "</li>";
}
else if (line[0..1] == "- ")
else if (line[1..2] == "- ")
{
line = "<li>" + line[1..] + "</li>";
}
} } catch{}
// Code block
else if (line.Contains("`"))
if (line.Contains("`"))
{
line = "<div>" + line[1..^1] + "</div>";
}
@ -119,7 +122,7 @@ font-family: sans-serif
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("MintHTML is a simple Markdown converter and renderer made by SweeZero.", "About", MessageBoxButtons.OK);
MessageBox.Show("MintHTML is a simple Markdown converter and renderer made by SweeZero's founder \"Swee.\"", "About", MessageBoxButtons.OK);
}
private void button2_Click(object sender, EventArgs e)
@ -235,5 +238,10 @@ font-family: monospace
serifToolStripMenuItem.Checked = false;
chromiumWebBrowser1.LoadHtml(css + htmlfile);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}