@bloklabs/server 1.14.0 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +26 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -74,10 +74,36 @@ public sealed class ArticleExport(IBlokDocumentConverter blok, ILogger<ArticleEx
74
74
  | `ToHtmlAsync` | the document's HTML |
75
75
  | `ToPlainTextAsync` | the document's readable text; `includeHiddenText: true` also emits an image's alt, a video/file url, an embed source, an audio title/artist/url and a bookmark description/url |
76
76
  | `FromMarkdownAsync` | the saved document, plus what Markdown could not carry into it |
77
+ | `FromHtmlAsync` | the saved document parsed out of HTML, plus what the HTML could not carry into it |
77
78
  | `ExtractTextsAsync` / `InjectTextsAsync` | the document's translatable strings, and the document with them put back |
78
79
  | `GetVersionAsync` | the `version` the editor stamps into a saved document |
79
80
  | `GetSchemaAsync` | the saved format as JSON Schema (draft 2020-12) |
80
81
 
82
+ ### Import HTML
83
+
84
+ `FromHtmlAsync` is the inverse of `ToHtmlAsync`. It takes a fragment or a whole
85
+ document and parses the structural subset a document body is made of: headings,
86
+ paragraphs, lists (nested, ordered, checklists), tables (merged cells included),
87
+ images, links and inline marks, code, blockquotes, toggles and dividers. Layout
88
+ containers are unwrapped and their children converted in place.
89
+
90
+ ```csharp
91
+ var import = await blok.FromHtmlAsync(html, ct);
92
+
93
+ foreach (var warning in import.Warnings)
94
+ {
95
+ // e.g. construct "iframe", action "dropped", detail "<iframe> and its contents are dropped…"
96
+ logger.LogInformation("{Construct} {Action}: {Detail}", warning.Construct, warning.Action, warning.Detail);
97
+ }
98
+
99
+ await Store(import.DocumentJson, ct);
100
+ ```
101
+
102
+ Read the warnings. Blok has no block for an embedded video, a form control or a
103
+ tag nobody has heard of, and every one of them comes back naming the tag rather
104
+ than disappearing. Storing the document without reading the report is how an
105
+ import loses content quietly.
106
+
81
107
  ### Translate a document without handing a model its JSON
82
108
 
83
109
  A model asked to translate a document's JSON breaks the structure. It drops
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloklabs/server",
3
- "version": "1.14.0",
3
+ "version": "1.15.1",
4
4
  "description": "Blok server delivery for ASP.NET Core, npm, and Docker — shared C# routes for file uploads and link previews.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JackUait",