📜 ⬆️ ⬇️

Source Code Highlighting

I rewrote and modified (especially for Habra, or rather for .NET blog) at my leisure a small module that highlights the source code of C #, VB.NET, HTML / XML / ASPX, JavaScript and SQL.

If you want to insert a piece of source code into a new entry or comment on an entry, use Source Code Highlighter , which will highlight your code.

There is support for line numbering and inserting line breaks, if you have marked “Disable auto-formatting” when writing a post.
')
Here is an example of the highlighted source code that this module issues:

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. /// <summary>
  11. /// Summary description for Test
  12. /// </ summary>
  13. public class Test
  14. {
  15. private int m_TestVar1;
  16. private float m_TestVar2;
  17. private DateTime m_TestVar3;
  18. public Test ()
  19. {
  20. //
  21. // TODO: Add constructor logic here
  22. //
  23. }
  24. public int TestVar1
  25. {
  26. get { return m_TestVar1; }
  27. set {m_TestVar1 = value ; }
  28. }
  29. public float TestVar2
  30. {
  31. get { return m_TestVar2; }
  32. set {m_TestVar2 = value ; }
  33. }
  34. public DateTime TestVar3
  35. {
  36. get { return m_TestVar3; }
  37. set {m_TestVar3 = value ; }
  38. }
  39. }
* This source code was highlighted with Source Code Highlighter .


Bugs, requests and suggestions leave in the comments. :)

I hope that this module will be useful for many, and not only for use in this blog.
Use on health!

PS
Link to the site will always hang in the description of the blog.

UPD # 1: Added the ability to highlight HTML / XML / ASPX code.
UPD # 2: Added the ability to quickly copy the code to the clipboard.
UPD # 3: Fixed numbering lines of code. Now you can copy the code to the clipboard without problems.

Source: https://habr.com/ru/post/24959/


All Articles