Skip to content

Commit

Permalink
Dev (#222)
Browse files Browse the repository at this point in the history
* cleanup code
* fix index out of range when only front matter present
* fix clipboard to DataUri
* allow per monitor dpi
* move commands
* move commands
* move commands
* refactor to use static
* refactor commands
* fix init problem
* refactor more commands
* refactor more commands
* refactor more commands
* refactor more commands
* fix openfile command
* move more commands
* main window refactored
* begin refactoring editor commands
* move more editor commands:
* move more commands
* refactor to commands
* update packages, reduce template
* make stylesheet less github like
* add list indent on tab
* add multi-jit startup
* fix redraw issues
* navigate to named anchors in same document #171
* only add to list items if it's increasing line count #172
* check if previous/previous line in list #173
* to enable newer common control styles
* move app manifest into solution items
* v1.30
* Create local.txt
* Add files via upload
* Add files via upload
* Update SpellingLanguages.cs
* Update SpellingLanguages.cs
* Update SpellingLanguages.cs
* sv translation
* add translations
* Add swedish translation to project
* fix crash
* CustomMarkdownConverter to use long file names
* fix CustomConverter by adding separate CustomConverterArgs setting, disable UI when set
* special case handling of blockquote in list #176
* 1.30.1
* cleanup
* add snytax highlighting styles
* update
* add russian translation
* v1.30.2
* refactor to vm
* create vm for main window
* add crash reporter
* remove intentional exception
* move crashreport initialization
* messing with UWA
* update to MahApp 1.3
* switch to win10 style toggle switches, add format section
* Show time near doc stats #194
* expand dialog for language translations #192
* add hypen snippet
* add hyphen snippet #195
* add spellcheck error color to theme settings #193`
* 1.31
* make about label style wider
* fix crash on tab at start of doc
* goto latest release instead of markdown.com #198
* update packages
* crash report fixes, limit spellling errors to 20 per paragraph, better detection of code blocks for spell check)
* refactor, docuemnt why
* update pandoc
* v1.32
  • Loading branch information
mike-ward authored Jan 2, 2017
1 parent 8964b89 commit 96e6147
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace MarkdownEdit.Commands
{
internal static class GoToMarkdownEditWebSiteCommand
internal static class GoToLatestReleaseCommand
{
public static readonly RoutedCommand Command = new RoutedCommand();

static GoToMarkdownEditWebSiteCommand()
static GoToLatestReleaseCommand()
{
Application.Current.MainWindow.CommandBindings.Add(new CommandBinding(Command, Execute));
}

private static void Execute(object sender, ExecutedRoutedEventArgs e) =>
Process.Start(new ProcessStartInfo("http://markdownedit.com"));
Process.Start(new ProcessStartInfo("https://github.com/mike-ward/Markdown-Edit/releases/latest"));
}
}
1 change: 1 addition & 0 deletions src/MarkdownEdit/Commands/SnippetTabCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private static int FindPrevWordStart(ITextSource textSource, int offset)

private static int StartOfListOffset(ITextSource textSource, int offset)
{
if (offset == 0) return -1;
var startOffset = offset - 1;
while (startOffset > 0 && char.IsWhiteSpace(textSource.GetCharAt(startOffset)))
{
Expand Down
22 changes: 1 addition & 21 deletions src/MarkdownEdit/Controls/DisplaySettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</Style>

<Style x:Key="AboutLabelStyle" BasedOn="{StaticResource LabelStyle}" TargetType="TextBlock">
<Setter Property="Width" Value="75" />
<Setter Property="Width" Value="125" />
</Style>

<Style x:Key="HyperlinkStyle" TargetType="Hyperlink">
Expand Down Expand Up @@ -245,26 +245,6 @@
</Hyperlink>
</TextBlock>
</StackPanel>
<!--<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource AboutLabelStyle}">Twitter</TextBlock>
<TextBlock>
<Hyperlink NavigateUri="https://twitter.com/mikeward_aa"
Style="{StaticResource HyperlinkStyle}"
RequestNavigate="HyperlinkOnRequestNavigate">
mikeward_aa
</Hyperlink>
</TextBlock>
</StackPanel>-->
<!--<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource AboutLabelStyle}" Text="{i18N:Localize settings-source}" />
<TextBlock>
<Hyperlink NavigateUri="https://github.com/mike-ward/Markdown-Edit"
Style="{StaticResource HyperlinkStyle}"
RequestNavigate="HyperlinkOnRequestNavigate">
GitHub
</Hyperlink>
</TextBlock>
</StackPanel>-->
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource AboutLabelStyle}" Text="{i18N:Localize settings-donate}" />
<TextBlock>
Expand Down
2 changes: 1 addition & 1 deletion src/MarkdownEdit/Controls/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<Button
Style="{StaticResource NewVersionCommandWindowButtonStyle}"
FontFamily="Segoe UI Symbol"
Command="{x:Static commands:GoToMarkdownEditWebSiteCommand.Command}"
Command="{x:Static commands:GoToLatestReleaseCommand.Command}"
Content="&#xE182;"
ToolTip="{i18N:Localize tooltip-new-version}" />
</StackPanel>
Expand Down
19 changes: 11 additions & 8 deletions src/MarkdownEdit/Controls/Preview.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,19 @@ public Preview()
Browser.Navigating += BrowserOnNavigating;
Browser.PreviewKeyDown += BrowserPreviewKeyDown;
Browser.MessageHook += BrowserOnMessageHook;
Browser.Unloaded += (s, e) => ApplicationCommands.Close.Execute(null, Application.Current.MainWindow);
UpdatePreview = Utility.Debounce<Editor>(editor => Dispatcher.InvokeAsync(() => Update(editor.Text)));
DocumentStatisticMode = StatisticMode.Word;

Browser.Unloaded += (s, e) =>
{
try
{
ApplicationCommands.Close.Execute(null, Application.Current.MainWindow);
}
catch (NullReferenceException)
{
}
};
}

public StatisticMode DocumentStatisticMode { get; set; }
Expand Down Expand Up @@ -110,7 +120,6 @@ private async void Update(string markdown)
try
{
UpdateBaseTag();
ScrollSync();
var div = GetContentsDiv();
if (div == null) return;

Expand All @@ -129,12 +138,6 @@ await Task.Run(() =>
}
}

private void ScrollSync()
{
var document = Browser.Document as IHTMLDocument2;
document.parentWindow.onscroll = new Action<object, IHTMLEventObj>((s, e) => Console.WriteLine("scroll"));
}

public void UpdateDocumentStatistics(string innerText)
{
CharacterCount = innerText.Length;
Expand Down
Binary file modified src/MarkdownEdit/Lib/pandoc.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions src/MarkdownEdit/MarkdownEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
<HintPath>..\packages\AvalonEdit.5.0.3\lib\Net40\ICSharpCode.AvalonEdit.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=1.3.0.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath>
<Reference Include="MahApps.Metro, Version=1.4.0.42, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.4.0\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -135,7 +135,7 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<HintPath>..\packages\MahApps.Metro.1.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -176,7 +176,7 @@
<Compile Include="Commands\HelpCommand.cs" />
<Compile Include="Commands\IncreaseEditorMarginCommand.cs" />
<Compile Include="Commands\DecreaseEditorMarginCommand.cs" />
<Compile Include="Commands\GoToMarkdownEditWebSiteCommand.cs" />
<Compile Include="Commands\GoToLatestReleaseCommand.cs" />
<Compile Include="Commands\IncreaseFontSizeCommand.cs" />
<Compile Include="Commands\InsertBlockQuoteCommand.cs" />
<Compile Include="Commands\InsertFileCommand.cs" />
Expand Down
3 changes: 1 addition & 2 deletions src/MarkdownEdit/Models/AbstractSyntaxTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public static bool PositionSafeForSmartLink(Block ast, int start, int length)
{
if (ast == null) return true;
var end = start + length;
var blockTags = new[]
{BlockTag.FencedCode, BlockTag.HtmlBlock, BlockTag.IndentedCode, BlockTag.ReferenceDefinition};
var blockTags = new[] {BlockTag.FencedCode, BlockTag.HtmlBlock, BlockTag.IndentedCode, BlockTag.ReferenceDefinition};
var inlineTags = new[] { InlineTag.Code, InlineTag.Link, InlineTag.RawHtml, InlineTag.Image };
var lastBlockTag = BlockTag.Document;

Expand Down
8 changes: 7 additions & 1 deletion src/MarkdownEdit/Models/FileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ public static FileSystemWatcher WatchFile(this string file, Action onChange)
}
finally
{
fileWatcher.EnableRaisingEvents = true;
try
{
fileWatcher.EnableRaisingEvents = true;
}
catch (ObjectDisposedException)
{
}
}
};
fileWatcher.EnableRaisingEvents = true;
Expand Down
12 changes: 10 additions & 2 deletions src/MarkdownEdit/Models/Markdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,16 @@ public static string FromMicrosoftWord(string path)
public static string ToMicrosoftWord(string markdown, string path) =>
Pandoc(ResolveImageUrls(ToHtml(markdown)), $"-f html -t docx -o \"{path}\"");

public static byte[] HtmlToPdf(string html) =>
new HtmlToPdfConverter().GeneratePdf(ResolveImageUrls(html));
public static byte[] HtmlToPdf(string html)
{
var converter = new HtmlToPdfConverter
{
CustomWkHtmlPageArgs = " --no-stop-slow-scripts" +
" --javascript-delay 5000" +
" --disable-smart-shrinking"
};
return converter.GeneratePdf(ResolveImageUrls(html));
}

public static string Pandoc(string text, string args)
{
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEdit/Models/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace MarkdownEdit.Models
{
internal static class Version
{
public const string VersionNumber = "1.31";
public const string VersionNumber = "1.32";

public static async Task<bool> IsCurrentVersion()
{
Expand All @@ -20,7 +20,7 @@ public static async Task<bool> IsCurrentVersion()
|| string.IsNullOrWhiteSpace(version)
|| version == VersionNumber;
}
}
}
catch (Exception)
{
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEdit/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: AssemblyVersion("1.31.0")]
[assembly: AssemblyFileVersion("1.31.0")]
[assembly: AssemblyVersion("1.32.0")]
[assembly: AssemblyFileVersion("1.32.0")]
[assembly: Guid("A9A0AE86-ED91-498F-A9F9-DB669C9879CE")]
18 changes: 14 additions & 4 deletions src/MarkdownEdit/SpellCheck/SpellCheckProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using MarkdownEdit.Controls;
using MarkdownEdit.Models;

namespace MarkdownEdit.SpellCheck
{
Expand Down Expand Up @@ -99,14 +100,21 @@ private void DoSpellCheck()
foreach (var currentLine in visualLines)
{
var startIndex = 0;
var startOfLine = currentLine.FirstDocumentLine.Offset;
var lengthOfLine = currentLine.LastDocumentLine.EndOffset - startOfLine;

var originalText = _editor.EditBox.Document.GetText(currentLine.FirstDocumentLine.Offset,
currentLine.LastDocumentLine.EndOffset - currentLine.FirstDocumentLine.Offset);
var originalText = _editor.EditBox.Document.GetText(startOfLine, lengthOfLine);

originalText = Regex.Replace(originalText, "[\\u2018\\u2019\\u201A\\u201B\\u2032\\u2035]", "'");
var textWithout = originalText;
if (userSettings.SpellCheckIgnoreCodeBlocks)
{
if (!AbstractSyntaxTree.PositionSafeForSmartLink(_editor.AbstractSyntaxTree, startOfLine, lengthOfLine))
{
// Generally speaking, if it's not safe to insert a link, it's probably something we don't
// want spell checked.
continue;
};
if (_codeBlock.IsMatch(originalText))
{
var firstChar = originalText.FirstOrDefault(c => !char.IsWhiteSpace(c));
Expand All @@ -119,11 +127,12 @@ private void DoSpellCheck()
if (userSettings.SpellCheckIgnoreCodeBlocks) textWithout = _inlineCode.Replace(textWithout, "");
var words = _wordSeparatorRegex.Split(textWithout).Where(s => !string.IsNullOrEmpty(s));
if (userSettings.SpellCheckIgnoreAllCaps) words = words.Where(w => w != w.ToUpper()).ToArray();
if (userSettings.SpellCheckIgnoreWordsWithDigits)
words = words.Where(w => !Regex.Match(w, "\\d").Success).ToArray();
if (userSettings.SpellCheckIgnoreWordsWithDigits) words = words.Where(w => !Regex.Match(w, "\\d").Success).ToArray();
var errors = 0;

foreach (var word in words)
{
if (errors >= 20) break;
var trimmedWord = word.Trim('\'', '_', '-');

var num = currentLine.FirstDocumentLine.Offset
Expand All @@ -134,6 +143,7 @@ private void DoSpellCheck()
{
var textSegment = new TextSegment {StartOffset = num, Length = word.Length};
_spellCheckRenderer.ErrorSegments.Add(textSegment);
errors += 1;
}

startIndex = originalText.IndexOf(word, startIndex, StringComparison.InvariantCultureIgnoreCase)
Expand Down
2 changes: 1 addition & 1 deletion src/MarkdownEdit/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="AvalonEdit" version="5.0.3" targetFramework="net46" />
<package id="CommonMark.NET" version="0.14.0" targetFramework="net46" />
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net46" />
<package id="MahApps.Metro" version="1.3.0" targetFramework="net46" />
<package id="MahApps.Metro" version="1.4.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="NHunspell" version="1.2.5554.16953" targetFramework="net452" />
<package id="NReco.PdfGenerator" version="1.1.12.0" targetFramework="net46" />
Expand Down
14 changes: 7 additions & 7 deletions src/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=4.14.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.14.0\lib\net45\FluentAssertions.dll</HintPath>
<Reference Include="FluentAssertions, Version=4.18.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.18.0\lib\net45\FluentAssertions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FluentAssertions.Core, Version=4.14.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.14.0\lib\net45\FluentAssertions.Core.dll</HintPath>
<Reference Include="FluentAssertions.Core, Version=4.18.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.18.0\lib\net45\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.4.9.5, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.4.9.5\lib\Net45\HtmlAgilityPack.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=1.3.0.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath>
<Reference Include="MahApps.Metro, Version=1.4.0.42, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.4.0\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand All @@ -81,7 +81,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<HintPath>..\packages\MahApps.Metro.1.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
Expand Down
4 changes: 2 additions & 2 deletions src/UnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.14.0" targetFramework="net46" />
<package id="FluentAssertions" version="4.18.0" targetFramework="net46" />
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net46" />
<package id="MahApps.Metro" version="1.3.0" targetFramework="net46" />
<package id="MahApps.Metro" version="1.4.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="NReco.PdfGenerator" version="1.1.12.0" targetFramework="net46" />
</packages>
2 changes: 1 addition & 1 deletion src/Wix/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Product Id="*"
Name="Markdown Edit"
Language="1033"
Version="1.31.0"
Version="1.32.0"
Manufacturer="Mike Ward"
UpgradeCode="77d4d41b-4443-42c6-87dd-20771c9bb031">

Expand Down

0 comments on commit 96e6147

Please sign in to comment.