{"id":28547484,"url":"https://github.com/pingmantools/litehtmlsharp","last_synced_at":"2025-07-07T18:31:45.200Z","repository":{"id":56249209,"uuid":"81506561","full_name":"PingmanTools/LiteHtmlSharp","owner":"PingmanTools","description":"LiteHtmlSharp is a C# cross-platform library for HTML/CSS(2/3) visualization - self contained, fast and small","archived":false,"fork":false,"pushed_at":"2025-06-27T01:21:36.000Z","size":85721,"stargazers_count":10,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-27T01:49:17.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PingmanTools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-09T23:48:42.000Z","updated_at":"2025-06-07T13:33:50.000Z","dependencies_parsed_at":"2022-08-15T15:21:05.355Z","dependency_job_id":null,"html_url":"https://github.com/PingmanTools/LiteHtmlSharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PingmanTools/LiteHtmlSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FLiteHtmlSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FLiteHtmlSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FLiteHtmlSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FLiteHtmlSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PingmanTools","download_url":"https://codeload.github.com/PingmanTools/LiteHtmlSharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FLiteHtmlSharp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264130514,"owners_count":23562042,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T00:30:34.275Z","updated_at":"2025-07-07T18:31:45.192Z","avatar_url":"https://github.com/PingmanTools.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿\n\n# Background and \"features\"\n\nLiteHtmlSharp is a C# cross-platform library for HTML/CSS(2/3) visualization - self contained, fast and small.  \nThe HTML parser/renderer is based on the fantastic [litehtml](https://github.com/litehtml/litehtml) C++ library, \nand the drawing is done with platform-native controls (currently WPF and Cocoa).\n\n\u003e litehtml is the lightweight HTML rendering engine with CSS2/CSS3 support. Note, litehtml itself does\n\u003e not draw any text, pictures or other graphics and litehtml does not depend of any image/draw/font library. \n\u003e You are free to use any library to draw images, fonts and any other graphics. litehtml just parses\n\u003e HTML/CSS and places the HTML elements into right position (renders HTML).\n\n\n### HTML Visualization?  What does that mean?\n\nWe wanted to use HTML/css to do splash screen, about-box design, new version availability messaging, new \nuser \"greeting\", getting started documentation, etc.  We wanted to have this tightly integrated, completely\nin our control (no platform right-click menus, no Windows Internet Explorer compatibility problems) and \nappropriately sized (no 50mb distributions that require a chrome browser process running).\n\nWe couldn't find anything for .NET / C# that met our needs, but [litehtml](https://github.com/litehtml/litehtml)\nsparked our imagination, and it's a stable, awesome library that knows how to do layout (but not draw) for\njust about everything we needed.\n\nSo we wrapped [litehtml](https://github.com/litehtml/litehtml) to make it work for C#, then built a drawing\nabstraction layer and OSX and WPF implementations.  Cool.  It *could* work for Android, iOS, Linx, too - we've\njust not done the visualization part for that yet.  Several other parts are not yet fully flushed out, too.\n\n\n## LiteHtmlLib (C++)\nThe first layer of this library is a C++ project (see the LiteHtmlLib directory) that wraps the litehtml \n[document_container](https://github.com/litehtml/litehtml/wiki/document_container) abstract class\nin a way that the C# PInvoke system can interact with. This code along with the litehtml C++ is compiled\ninto a native binary that our C# wrapper consumes with DLLImports. We've provided precompiled win32/64 DLLs\nand a OSX 32/64 dylib.\n\n### Compiling DLL on Windows\nUse the `LiteHtmlLib/LiteHtmlLib.vcxproj` project in Visual Studio 2015.\n\n### Compiling on OSX\nInstall CMake. Open `LiteHtmlLib/LiteHtml.dyblib.mdproj` in Xamarin Studio and run build. \n\nOr just call the build script from terminal:\n\n```bash\ncd LiteHtmlLib\nsh build.sh\n```\n\n### Compiling on Linux\nThe above build script should work but hasn't been tested.\n\n\n## LiteHtmlSharp\nSecond layer is a C# shared project that provides a C# abstract class equivalent of the C++ document_container. \nMost of the of the structs and class methods have been ported.  \n\n#### Usage Documentation\nIf you are wanting to just display HTML in a WPF or Xamarin.Mac/MonoMac app, then use our platform\nimplementations (see below). Otherwise you will have to derive the base C# container and implement\nthe drawing API for your platform. The `Container` class definition more-or-less mirrors the\noriginal C++ one but with C#-style syntax. The API should be close enough to be able to\nuse the original litehtml usage documentation: \n[document_container](https://github.com/litehtml/litehtml/wiki/document_container) and\n[how to use litehtml](https://github.com/litehtml/litehtml/wiki/How-to-use-litehtml)\n\nOur WPF \u0026 Mac implementations can be used as examples when implementing a new platform. \nSome cool, unimplemented ideas:\n\n* An OpenTK implementation (provides html -\u003e OpenGL rendering on most platforms)\n* A Mono.Cairo implementation\n* A Winforms GTK+ (System.Drawing) implementation\n\n\n\n## Platform Implementations\n\n### Core Graphics (Apple platforms)\nThe LiteHtmlSharp.CoreGraphics shared project contains `CGContainer` (derived from litehtml container) which draws to\na `CoreGraphics.CGContext` instance. Xamarin.iOS and Xamarin.Mac Unified projects can use this project.\n\n### Xamarin.Mac\nThe `LiteHtmlSharp.Mac` library contains a litehtml-`NSView` and a litehtml-`NSWindow`. Usage examples:\n\n#### LiteHtmlNSView\n```cs\nvar myView = new LiteHtmlNSView(new CGRect(0, 0, 400, 500), File.ReadAllText(\"master.css\"));\nmyView.LiteHtmlContainer.ImportCssCallback = (url, baseUrl) =\u003e File.ReadAllText(url);\nmyView.LiteHtmlContainer.LoadImageCallback = (url) =\u003e File.ReadAllBytes(url);\nmyView.LoadHtml(File.ReadAllText(\"index.html\"));\nwindowContentView.AddSubview(myView);\n```\n\n#### LiteHtmlNSWindow\n```cs\nvar htmlWindow = new LiteHtmlNSWindow(\n                    new CGRect(0, 0, 400, 400), \n                    NSWindowStyle.Closable | NSWindowStyle.Titled | NSWindowStyle.Resizable, \n                    File.ReadAllText(\"master.css\")\n                );\nhtmlWindow.LiteHtmlContainer.ImportCssCallback = (url, baseUrl) =\u003e File.ReadAllText(url);\nhtmlWindow.LiteHtmlContainer.LoadImageCallback = (url) =\u003e File.ReadAllBytes(url);\nhtmlWindow.LiteHtmlView.LoadHtml(File.ReadAllText(\"index.html\"));\nhtmlWindow.MakeKeyAndOrderFront(this);\n```\n\n### WPF\n```cs\n// code\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingmantools%2Flitehtmlsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingmantools%2Flitehtmlsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingmantools%2Flitehtmlsharp/lists"}