Skip to content

Commit

Permalink
#28 - Footnotes don't work - jump to the correct anchor on the page
Browse files Browse the repository at this point in the history
  • Loading branch information
mohzy83 committed Dec 10, 2022
1 parent 18920be commit 6099dd9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
14 changes: 8 additions & 6 deletions NppMarkdownPanel/Forms/MarkdownPreviewForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion NppMarkdownPanel/Forms/MarkdownPreviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,28 @@ protected override void WndProc(ref Message m)

private void webBrowserPreview_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (e.Url.ToString() != "about:blank")
if (!e.Url.ToString().StartsWith("about:blank"))
{
e.Cancel = true;
var p = new Process();
p.StartInfo = new ProcessStartInfo(e.Url.ToString());
p.Start();
}
else
{
// Jump to correct anchor on the page
if (e.Url.ToString().Contains("#"))
{
var urlParts = e.Url.ToString().Split('#');
e.Cancel = true;
var element = webBrowserPreview.Document.GetElementById(urlParts[1]);
if (element != null)
{
element.Focus();
element.ScrollIntoView(true);
}
}
}
}

private void btnSaveHtml_Click(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions NppMarkdownPanel/Forms/MarkdownPreviewForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@
<data name="btnSaveHtml.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB+SURBVDhPY/j27Vs4EL8B4v8kYpCecJABb7QL1vxnCJ5D
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAB+SURBVDhPY/j27Vs4EL8B4v8kYpCecJABb7QL1vxnCJ5D
EgbpAekFGYBVATEYrBfZgA/vPxKFh7MBpOJBagA2PyNjZLW0NQCdjy4OwmC9X758uVM8/xiGBnQ+ujgI
gw34+vWrDLIh6AqRNSOLgzDYABCAGQISACkC0cThb/8BXmPqvKWoVTAAAAAASUVORK5CYII=
</value>
</data>
<data name="btnPrintPreview.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADgSURBVDhPrZGxDcIwEEW9AYzACAxAlRVoocsUDJCaAVwh
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAADgSURBVDhPrZGxDcIwEEW9AYzACAxAlRVoocsUDJCaAVwh
MQAdNGmoIyQKWmACJ+A4peFbZ9mRgzESX/o653L/6Zywv0kppb/4JIQY03goDGVZ9tGccwPpum5Ckb4s
oBZNYAspigIQIaWcUswpBeBDKOaUCoAxSzGnGMB3FADLp9StbPX7nrqpH78BDtVNj5YbPVvtTN1X1wAS
BSB0PN/NICqesUkygM15bxiboO/3BgH4rxawLS9mMHkDCovFujQA6+Rv4IdR8dJ3nucm5Bt9ijvAUDhm
Expand Down

0 comments on commit 6099dd9

Please sign in to comment.