Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion UniversalMarkdown.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalMarkdownTestApp", "UniversalMarkdownTestApp\UniversalMarkdownTestApp.csproj", "{E931F68D-FCC8-4E6F-A718-379672D533CD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalMarkdownUnitTests", "UniversalMarkdownUnitTests\UniversalMarkdownUnitTests.csproj", "{519A9FE1-E530-4764-804E-A41F0D68D6B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalMarkdown", "UniversalMarkdown\UniversalMarkdown.csproj", "{9FFC3B68-696A-4342-A2B8-2EADDDEF7FF9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalMarkdownPortable", "UniversalMarkdownPortable\UniversalMarkdownPortable.csproj", "{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -77,6 +79,22 @@ Global
{9FFC3B68-696A-4342-A2B8-2EADDDEF7FF9}.Release|x64.Build.0 = Release|x64
{9FFC3B68-696A-4342-A2B8-2EADDDEF7FF9}.Release|x86.ActiveCfg = Release|x86
{9FFC3B68-696A-4342-A2B8-2EADDDEF7FF9}.Release|x86.Build.0 = Release|x86
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|ARM.Build.0 = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|x64.ActiveCfg = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|x64.Build.0 = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Debug|x86.Build.0 = Debug|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|Any CPU.Build.0 = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|ARM.ActiveCfg = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|ARM.Build.0 = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|x64.ActiveCfg = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|x64.Build.0 = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|x86.ActiveCfg = Release|Any CPU
{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
26 changes: 20 additions & 6 deletions UniversalMarkdown/Display/XamlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ public XamlRenderer(MarkdownDocument document, ILinkRegister linkRegister)
/// Gets or sets the word wrapping behavior.
/// </summary>
public TextWrapping TextWrapping { get; set; }

/// <summary>
/// Gets or sets the link foreground.
/// </summary>
public Brush LinkForeground { get; set; }


/// <summary>
Expand All @@ -340,11 +345,19 @@ public UIElement Render()

// Set background and border properties.
stackPanel.Background = Background;
#if WINDOWS_UWP
stackPanel.BorderBrush = BorderBrush;
stackPanel.BorderThickness = BorderThickness;
stackPanel.Padding = Padding;

return stackPanel;
#else
var border = new Border();
border.BorderBrush = BorderBrush;
border.BorderThickness = BorderThickness;
stackPanel.Margin = Padding;
border.Child = stackPanel;
return border;
#endif
}

// Helper class for holding persistent state.
Expand Down Expand Up @@ -537,7 +550,7 @@ private void RenderListElement(ListBlock element, UIElementCollection blockUIEle
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(ListGutterWidth) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });

for (int rowIndex = 0; rowIndex < element.Items.Count; rowIndex ++)
for (int rowIndex = 0; rowIndex < element.Items.Count; rowIndex++)
{
var listItem = element.Items[rowIndex];

Expand Down Expand Up @@ -816,7 +829,7 @@ private void RenderMarkdownLink(InlineCollection inlineCollection, MarkdownLinkI
{
// Regular ol' hyperlink.
var link = new Hyperlink();

link.Foreground = LinkForeground ?? Foreground;
// Register the link
this.linkRegister.RegisterNewHyperLink(link, element.Url);

Expand Down Expand Up @@ -845,7 +858,7 @@ private void RenderMarkdownLink(InlineCollection inlineCollection, MarkdownLinkI

// Now render it.
RenderSuperscriptRun(inlineCollection, fakeSuperscript, parent, context);

}
}

Expand All @@ -865,6 +878,7 @@ private void RenderHyperlink(InlineCollection inlineCollection, HyperlinkInline

// Make a text block for the link
Run linkText = new Run();
linkText.Foreground = LinkForeground ?? Foreground;
linkText.Text = CollapseWhitespace(context, element.Text);
link.Inlines.Add(linkText);

Expand Down Expand Up @@ -1007,7 +1021,7 @@ private string CollapseWhitespace(RenderContext context, string text)
{
bool dontOutputWhitespace = context.TrimLeadingWhitespace;
StringBuilder result = null;
for (int i = 0; i < text.Length; i ++)
for (int i = 0; i < text.Length; i++)
{
char c = text[i];
if (c == ' ' || c == '\t')
Expand Down Expand Up @@ -1119,7 +1133,7 @@ private bool AllTextIsSuperscript(IInlineContainer container, int superscriptLev
/// <param name="insertCaret"></param>
private void RemoveSuperscriptRuns(IInlineContainer container, bool insertCaret)
{
for (int i = 0; i < container.Inlines.Count; i ++)
for (int i = 0; i < container.Inlines.Count; i++)
{
var inline = container.Inlines[i];
if (inline is SuperscriptTextInline)
Expand Down
28 changes: 23 additions & 5 deletions UniversalMarkdown/MarkdownTextBlock.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public event EventHandler<OnMarkdownLinkTappedArgs> OnMarkdownLinkTapped
public MarkdownTextBlock()
{
this.InitializeComponent();
#if WINDOWS_UWP
RegisterPropertyChangedCallback(FontSizeProperty, OnPropertyChanged);
RegisterPropertyChangedCallback(BackgroundProperty, OnPropertyChanged);
RegisterPropertyChangedCallback(BorderBrushProperty, OnPropertyChanged);
Expand All @@ -85,6 +86,8 @@ public MarkdownTextBlock()
RegisterPropertyChangedCallback(FontWeightProperty, OnPropertyChanged);
RegisterPropertyChangedCallback(ForegroundProperty, OnPropertyChanged);
RegisterPropertyChangedCallback(PaddingProperty, OnPropertyChanged);
RegisterPropertyChangedCallback(LinkForegroundProperty, OnPropertyChanged);
#endif
}

#region Dependency properties
Expand Down Expand Up @@ -661,6 +664,21 @@ public Brush QuoteForeground
/// </summary>
public static readonly DependencyProperty QuoteForegroundProperty = DependencyProperty.Register(nameof(QuoteForeground), typeof(Brush),
typeof(MarkdownTextBlock), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 180, 180, 180)), new PropertyChangedCallback(OnPropertyChangedStatic)));
/// <summary>
/// Gets or sets the brush used to render the text inside a quote block. If this is
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside a quote block?

/// <c>null</c>, then <see cref="Foreground"/> is used.
/// </summary>
public Brush LinkForeground
{
get { return (Brush)GetValue(LinkForegroundProperty); }
set { SetValue(LinkForegroundProperty, value); }
}

/// <summary>
/// Gets the dependency property for <see cref="QuoteForeground"/>.
/// </summary>
public static readonly DependencyProperty LinkForegroundProperty = DependencyProperty.Register(nameof(LinkForeground), typeof(Brush),
typeof(MarkdownTextBlock), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 0,0,0)), new PropertyChangedCallback(OnPropertyChangedStatic)));

/// <summary>
/// Gets or sets the space outside of quote borders.
Expand Down Expand Up @@ -769,9 +787,8 @@ public TextWrapping TextWrapping
public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register(nameof(TextWrapping), typeof(TextWrapping),
typeof(MarkdownTextBlock), new PropertyMetadata(TextWrapping.Wrap, new PropertyChangedCallback(OnPropertyChangedStatic)));

#endregion


#endregion

/// <summary>
/// Calls OnPropertyChanged.
/// </summary>
Expand Down Expand Up @@ -865,6 +882,7 @@ private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
renderer.TableCellPadding = TableCellPadding;
renderer.TableMargin = TableMargin;
renderer.TextWrapping = TextWrapping;
renderer.LinkForeground = LinkForeground;
Content = renderer.Render();
}
catch (Exception ex)
Expand All @@ -878,7 +896,7 @@ private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
m_onMarkdownReady.Raise(this, args);
}

#region Link Logic
#region Link Logic

private void UnhookListeners()
{
Expand Down Expand Up @@ -943,6 +961,6 @@ private void Hyperlink_Click(Hyperlink sender, HyperlinkClickEventArgs args)
m_onMarkdownLinkTapped.Raise(this, eventArgs);
}

#endregion
#endregion
}
}
30 changes: 30 additions & 0 deletions UniversalMarkdownPortable/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UniversalMarkdownPortable")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UniversalMarkdownPortable")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
150 changes: 150 additions & 0 deletions UniversalMarkdownPortable/UniversalMarkdownPortable.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8B5FC8A3-F9C7-4AFE-9BE9-F6377B7928D9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UniversalMarkdownPortable</RootNamespace>
<AssemblyName>UniversalMarkdownPortable</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile32</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<Page Include="..\UniversalMarkdown\MarkdownTextBlock.xaml">
<Link>MarkdownTextBlock.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<TargetPlatform Include="Windows, Version=8.1" />
<TargetPlatform Include="WindowsPhoneApp, Version=8.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\UniversalMarkdown\Display\ILinkRegister.cs">
<Link>Display\ILinkRegister.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Display\MarkdownTable.cs">
<Link>Display\MarkdownTable.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Display\XamlRenderer.cs">
<Link>Display\XamlRenderer.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Helpers\Common.cs">
<Link>Helpers\Common.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Helpers\DebuggingReporter.cs">
<Link>Helpers\DebuggingReporter.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Helpers\SmartWeakEvent.cs">
<Link>Helpers\SmartWeakEvent.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\MarkdownTextBlock.xaml.cs">
<Link>MarkdownTextBlock.xaml.cs</Link>
<DependentUpon>MarkdownTextBlock.xaml</DependentUpon>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\CodeBlock.cs">
<Link>Parse\Blocks\CodeBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\HeaderBlock.cs">
<Link>Parse\Blocks\HeaderBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\HorizontalRuleBlock.cs">
<Link>Parse\Blocks\HorizontalRuleBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\LinkReferenceBlock.cs">
<Link>Parse\Blocks\LinkReferenceBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\ListBlock.cs">
<Link>Parse\Blocks\ListBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\ParagraphBlock.cs">
<Link>Parse\Blocks\ParagraphBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\QuoteBlock.cs">
<Link>Parse\Blocks\QuoteBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Blocks\TableBlock.cs">
<Link>Parse\Blocks\TableBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\BoldTextInline.cs">
<Link>Parse\Inlines\BoldTextInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\CodeInline.cs">
<Link>Parse\Inlines\CodeInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\HyperlinkInline.cs">
<Link>Parse\Inlines\HyperlinkInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\IInlineContainer.cs">
<Link>Parse\Inlines\IInlineContainer.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\IInlineLeaf.cs">
<Link>Parse\Inlines\IInlineLeaf.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\ILinkElement.cs">
<Link>Parse\Inlines\ILinkElement.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\ItalicTextInline.cs">
<Link>Parse\Inlines\ItalicTextInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\MarkdownLinkInline.cs">
<Link>Parse\Inlines\MarkdownLinkInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\StrikethroughTextInline.cs">
<Link>Parse\Inlines\StrikethroughTextInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\SuperscriptTextInline.cs">
<Link>Parse\Inlines\SuperscriptTextInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\Inlines\TextRunInline.cs">
<Link>Parse\Inlines\TextRunInline.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\MarkdownBlock.cs">
<Link>Parse\MarkdownBlock.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\MarkdownDocument.cs">
<Link>Parse\MarkdownDocument.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\MarkdownElement.cs">
<Link>Parse\MarkdownElement.cs</Link>
</Compile>
<Compile Include="..\UniversalMarkdown\Parse\MarkdownInline.cs">
<Link>Parse\MarkdownInline.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>