简体   繁体   English

Visual Studio的格式文档–如何用C#编写

[英]Visual Studio's Format Document – How to Write it in C#

I'm having a go at writing some C# code which overrides the Render method of the System.Web.UI.Page and then reformats the HTML before presenting it to the browser. 我正在写一些C#代码,该代码重写System.Web.UI.Page的Render方法,然后在将HTML呈现给浏览器之前重新格式化HTML。 This is purely experimental so overhead is not a concern right now. 这纯粹是实验性的,因此目前无需担心开销。

I'm perhaps a little learned in the ways of the regular expression and would like to utilise them here, but I can't seem to think of a real concise and elegant way of nicely formatting a HTML document. 我可能对正则表达式的方法有些了解,并且想在这里使用它们,但是我似乎无法想到一种很好的简洁而优雅的方式来格式化HTML文档。 I've managed to completely minify the HTML using regex, but as for correctly indenting it, I'm stumped. 我设法使用正则表达式完全缩小了HTML,但是为了正确缩进,我很困惑。

So, if you had a string of HTML, using C#, how would you reformat it in much the same way as Visual Studio's Format Document function does? 因此,如果您有使用C#编写的HTML字符串,您将如何以与Visual Studio的“格式文档”函数相同的方式重新格式化它? Any ideas would be greatly appreciated. 任何想法将不胜感激。

Use Tidy . 使用Tidy I have used this .net wrapper quite successfully. 我已经非常成功地使用了.net包装器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将excel文件读入visual studio(c#)并与数据库匹配(在visual studio中)将匹配的结果写入word文档 - reading excel file into visual studio (c#) and matching with database(in visual studio) write matched results into word document 如何强制用户在Visual Studio for C#中记录类成员? - How to force user to document a class member in Visual Studio for C#? 如何在Visual Studio中编写C#单元测试? - How to write a C# unit test in Visual Studio? 如何在 Visual Studio 2010 中为 c# 安装程序编写自定义操作? - how to write custom action for a c# installer in visual studio 2010? C# 文件的 Visual Studio“文档大纲” - Visual Studio "document outline" for C# file 正确的C#Visual Studio查询格式 - Correct format of a query for C# visual studio C# arrays 的 Visual Studio 格式说明符? - Visual Studio format specifier for C# arrays? 如何在微软新的 Visual Studio Code 中编译 c#? - How to compile c# in Microsoft's new Visual Studio Code? 在Visual Studio中自动设置文档格式? - Automatically Format Document in Visual Studio? Visual C#-如何将文本写入Word文档模板? - Visual C# - How do I write text to a Word Document Template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM