diff --git a/Form1.Designer.cs b/Form1.Designer.cs
index 26becb4..41755c6 100644
--- a/Form1.Designer.cs
+++ b/Form1.Designer.cs
@@ -42,6 +42,7 @@
Opener = new OpenFileDialog();
Saver = new SaveFileDialog();
groupBox4 = new GroupBox();
+ chromiumWebBrowser1 = new CefSharp.WinForms.ChromiumWebBrowser();
progressBar1 = new ProgressBar();
button4 = new Button();
button3 = new Button();
@@ -72,6 +73,7 @@
//
// openDevToolsToolStripMenuItem
//
+ openDevToolsToolStripMenuItem.Enabled = false;
openDevToolsToolStripMenuItem.Name = "openDevToolsToolStripMenuItem";
openDevToolsToolStripMenuItem.Size = new Size(154, 22);
openDevToolsToolStripMenuItem.Text = "Open DevTools";
@@ -149,6 +151,7 @@
//
// groupBox4
//
+ groupBox4.Controls.Add(chromiumWebBrowser1);
groupBox4.Controls.Add(progressBar1);
groupBox4.Controls.Add(button4);
groupBox4.Dock = DockStyle.Fill;
@@ -160,12 +163,23 @@
groupBox4.Text = "Preview";
groupBox4.Enter += groupBox4_Enter;
//
+ // chromiumWebBrowser1
+ //
+ chromiumWebBrowser1.ActivateBrowserOnCreation = false;
+ chromiumWebBrowser1.Dock = DockStyle.Fill;
+ chromiumWebBrowser1.Location = new Point(3, 47);
+ chromiumWebBrowser1.Name = "chromiumWebBrowser1";
+ chromiumWebBrowser1.Size = new Size(794, 328);
+ chromiumWebBrowser1.TabIndex = 3;
+ chromiumWebBrowser1.LoadingStateChanged += chromiumWebBrowser1_LoadingStateChanged;
+ //
// progressBar1
//
progressBar1.Dock = DockStyle.Top;
progressBar1.Location = new Point(3, 42);
progressBar1.Name = "progressBar1";
progressBar1.Size = new Size(794, 5);
+ progressBar1.Style = ProgressBarStyle.Marquee;
progressBar1.TabIndex = 2;
//
// button4
@@ -274,5 +288,6 @@
private GroupBox groupBox3;
private Button button2;
private TextBox textBox2;
+ private CefSharp.WinForms.ChromiumWebBrowser chromiumWebBrowser1;
}
}
diff --git a/Form1.cs b/Form1.cs
index 9bf3041..2cc85e2 100644
--- a/Form1.cs
+++ b/Form1.cs
@@ -5,7 +5,6 @@ namespace MintHTML
{
public partial class Form1 : Form
{
- ChromiumWebBrowser chromiumWebBrowser1;
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string markfile;
string htmlfile = "
Welcome to MintHTML
Open a markdown file and press \"Render preview\" to see the output here.
";
@@ -16,7 +15,8 @@ background-color: #F3F3F3;
border: solid;
border-width: 1px
}
-";
+
+";
string css;
// Custom functions
private void convert()
@@ -28,41 +28,50 @@ border-width: 1px
while ((line = reader.ReadLine()) != null)
{
// Header 1
- if (line.Contains("# "))
+ if (line[0..1] == "# ")
{
line = "" + line[1..] + "
";
}
// Header 2
- else if (line.Contains("## "))
+ else if (line[0..2] == "## ")
{
line = "" + line[1..] + "
";
}
// Header 3
- else if (line.Contains("### "))
+ else if (line[0..3] == "### ")
{
line = "" + line[1..] + "
";
}
// Header 4
- else if (line.Contains("#### "))
+ else if (line[0..4] == "#### ")
{
line = "" + line[1..] + "
";
}
// Header 5
- else if (line.Contains("##### "))
+ else if (line[0..5] == "##### ")
{
line = "" + line[1..] + "
";
}
// Header 6
- else if (line.Contains("###### "))
+ else if (line[0..6] == "###### ")
{
line = "" + line[1..] + "
";
}
+ // Bullet point
+ else if (line[0..1] == "* ")
+ {
+ line = "- " + line[1..] + "
";
+ }
+ else if (line[0..1] == "- ")
+ {
+ line = "- " + line[1..] + "
";
+ }
// Code block
else if (line.Contains("`"))
{
@@ -83,12 +92,14 @@ border-width: 1px
{
if (File.Exists(appdata + "/SweeZero/MintHTML/RootCache/lockfile"))
{
- if (MessageBox.Show("There is another instance of MintHTML running. If there isn't, press Yes to try opening anyways.","Cef Warning",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes)
+ if (MessageBox.Show("There is another instance of MintHTML running. If there isn't, press Yes to try opening anyways.", "Cef Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
try
{
File.Delete(appdata + "/SweeZero/MintHTML/RootCache/lockfile");
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
MessageBox.Show(ex.Message, "Cef Error (fatal)", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@@ -96,16 +107,9 @@ border-width: 1px
var settings = new CefSettings()
{
RootCachePath = appdata + "/SweeZero/MintHTML/RootCache",
- LogFile = appdata + "/SweeZero/MintHTML/CefSharp.log",
- LogSeverity = LogSeverity.Default
};
- Cef.Initialize(settings);
- chromiumWebBrowser1 = new ChromiumWebBrowser();
- chromiumWebBrowser1.LoadingStateChanged += chromiumWebBrowser1_LoadingStateChanged;
- chromiumWebBrowser1.Dock = DockStyle.Fill;
InitializeComponent();
- groupBox4.Controls.Add(chromiumWebBrowser1);
- chromiumWebBrowser1.BringToFront();
+ Cef.Initialize(settings);
css = @"