本周的NuGet软件包:MarkdownLog使日志文件更漂亮

While I'm not 100% gaga over Markdown as I know many of you are, I definitely appreciate it's usefulness and it's clarity. Some folks would say I shouldn't rest until every binary document on my hard drive has been converted to Markdown. I say, nay nay. That said, I totally dig MarkdownPad and you should use it every day. It's lovely.

虽然我不像你们中的许多人那样对Markdown感到100%的争执,但我绝对赞赏它的用处和清晰度。 有些人会说,在硬盘上的每个二进制文件都转换为Markdown之前,我不应该休息。 我说,不,不。 也就是说,我完全挖掘了MarkdownPad ,您应该每天使用它。 好可爱

If you don't want to install anything, check out http://dillinger.io and quickly edit some Markdown in the browser.

如果您不想安装任何东西,请访问http://dillinger.io并在浏览器中快速编辑一些Markdown。

But, I digress.

但是,我离题了。

Note: Be sure to check out all the NuGet packages of the week! There's more!

注意:请务必查看本周所有的Nu​​Get软件包! 还有更多!

The general idea behind Markdown is that HTML is way too complex for 90% of what you need, so rather than <ul> and <li> and all that, why not just express bullets with asterisks? We can all get behind that. There are many other simple Markdown syntaxes that you can learn in a few minutes. Once you've created some Markdown, you can easily generate PDFs, HTML, Word Documents, whatever you like.

Markdown的基本思想是HTML太复杂了,无法满足您90%的需求,因此,除了<ul>和<li>以及其他所有内容之外,为什么不只用星号表示项目符号呢? 我们都可以落后。 您可以在几分钟内学习许多其他简单的Markdown语法。 一旦创建了一些Markdown,就可以轻松生成PDF,HTML,Word文档,无论您喜欢什么。

Recently I stumbled upon Stuart Wheelwright's article on Using Markdown for Effective Logging over at CodeProject. Here's the first image borrowed from his excellent article where he clearly shows why Markdown is simpler than HTML:

最近,我偶然发现了Stuart Wheelwright在CodeProject上有关使用Markdown进行有效登录文章。 这是从他的出色文章中借来的第一张图片,他清楚地说明了为什么Markdown比HTML更简单:

Stuart has taken Markdown and created a wonderful little library called MarkdownLog. It's a brilliant little idea that one of us should have come up with first! Kudos to Stuart. ;)

Stuart已经采用Markdown并创建了一个很棒的小库MarkdownLog 。 这是一个绝妙的小主意,我们中的一个应该首先想到! 斯图尔特(Stuart) ;)

[MarkdownLog] is designed to make it trivial to produce Markdown formatted text from an application's data structures. Using just one line of code, a collection of .NET objects can be output as a table or list. And, because the output is Markdown, it can later be converted to HTML for publishing, if needed.

[MarkdownLog]旨在使从应用程序的数据结构中生成Markdown格式的文本变得微不足道。 仅使用一行代码,.NET对象的集合就可以作为表或列表输出。 并且,由于输出是Markdown,因此以后可以根据需要将其转换为HTML以进行发布。

Even better, MarkdownLog is a Portable Class Library (PCL) and can be used with any .NET platform, including iOS with Xamarin. In fact, it's an iPhone app written with Xamarin that compelled Stuart to write MarkdownLog.

更好的是,MarkdownLog是可移植类库(PCL),可与任何.NET平台一起使用,包括带有Xamarin的iOS。 实际上,这是一个用Xamarin编写的iPhone应用程序,它迫使Stuart编写MarkdownLog。

Here's one of his first examples. This C# code:

这是他的第一个例子。 此C#代码:

var myStrings = new[] { "John", "Paul", "Ringo", "George" };
Console.Write(myStrings.ToMarkdownBulletedList());

Gives you this simple Markdown.

给您这个简单的Markdown。

   * John
* Paul
* Ringo
* George

At this point, you are likely unimpressed. But wait! There's more! There's a whole series of nice extension methods that make it easy to create templates from objects of any shape. Here's another example of his:

在这一点上,您可能不为所动。 可是等等! 还有更多! 有很多不错的扩展方法,可以轻松地从任何形状的对象创建模板。 这是他的另一个例子:

var data = new[]
{
new{Name = "Meryl Streep", Nominations = 18, Awards=3},
new{Name = "Katharine Hepburn", Nominations = 12, Awards=4},
new{Name = "Jack Nicholson", Nominations = 12, Awards=3}
};

Console.Write(data.ToMarkdownTable());

This gives you a Markdown table, of course. This looks nothing like an HTML table, but remember, Markdown is source code that can be translated into other formats like HTML and PDF.

当然,这为您提供了Markdown表。 这看起来似乎不像HTML表格,但请记住,Markdown是可以转换为HTML和PDF等其他格式的源代码。

 Name              | Nominations | Awards
----------------- | -----------:| ------:
Meryl Streep | 18 | 3
Katharine Hepburn | 12 | 4
Jack Nicholson | 12 | 3

Be sure to explore the full CodeProject article and the home page for MarkdownLog. Think about how you could add this to your existing logging framework and create better logs for tests, builds, anything. Take a look at the HTML render of one of Stuarts's Test Suite Runs and tell me that you want immediately want to get to work updating your old .LOG files.

确保浏览完整的CodeProject文章MarkdownLog主页。 考虑如何将其添加到现有的日志记录框架中,并为测试,构建和其他任何内容创建更好的日志。 看一看Stuarts的Test Suite RunsHTML渲染,并告诉我您想立即开始更新旧的.LOG文件。

相关链接 (Related Links)

翻译自: https://www.hanselman.com/blog/nuget-package-of-the-week-markdownlog-makes-log-files-much-prettier

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值