@gmb/bitmark-parser-generator 5.24.0 → 5.26.0
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.
- package/dist/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/browser/cjs/index.cjs +1040 -17
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +175 -1
- package/dist/browser/esm/index.d.ts +175 -1
- package/dist/browser/esm/index.js +1038 -17
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli/main.js +1155 -75
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +1040 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -1
- package/dist/index.d.ts +175 -1
- package/dist/index.js +1038 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -221,6 +221,7 @@ declare const BitType: {
|
|
|
221
221
|
readonly dangerAlt: "danger-alt";
|
|
222
222
|
readonly dangerCollapsible: "danger-collapsible";
|
|
223
223
|
readonly definitionList: "definition-list";
|
|
224
|
+
readonly definitionListCollapsible: "definition-list-collapsible";
|
|
224
225
|
readonly definitionTerm: "definition-term";
|
|
225
226
|
readonly deleted: "deleted";
|
|
226
227
|
readonly details: "details";
|
|
@@ -501,6 +502,8 @@ declare const BitType: {
|
|
|
501
502
|
readonly smartStandardArticleNonNormativeCollapsible: "smart-standard-article-non-normative-collapsible";
|
|
502
503
|
readonly smartStandardArticleNormative: "smart-standard-article-normative";
|
|
503
504
|
readonly smartStandardArticleNormativeCollapsible: "smart-standard-article-normative-collapsible";
|
|
505
|
+
readonly smartStandardDefinitionListNonNormative: "smart-standard-definition-list-non-normative";
|
|
506
|
+
readonly smartStandardDefinitionListNormative: "smart-standard-definition-list-normative";
|
|
504
507
|
readonly smartStandardExampleNonNormative: "smart-standard-example-non-normative";
|
|
505
508
|
readonly smartStandardExampleNonNormativeCollapsible: "smart-standard-example-non-normative-collapsible";
|
|
506
509
|
readonly smartStandardExampleNormative: "smart-standard-example-normative";
|
|
@@ -551,6 +554,8 @@ declare const BitType: {
|
|
|
551
554
|
readonly smartStandardTableNormativeCollapsible: "smart-standard-table-normative-collapsible";
|
|
552
555
|
readonly standardArticleNonNormative: "standard-article-non-normative";
|
|
553
556
|
readonly standardArticleNormative: "standard-article-normative";
|
|
557
|
+
readonly standardDefinitionListNonNormative: "standard-definition-list-non-normative";
|
|
558
|
+
readonly standardDefinitionListNormative: "standard-definition-list-normative";
|
|
554
559
|
readonly standardExampleNonNormative: "standard-example-non-normative";
|
|
555
560
|
readonly standardExampleNormative: "standard-example-normative";
|
|
556
561
|
readonly standardImageFigureNonNormative: "standard-image-figure-non-normative";
|
|
@@ -849,6 +854,7 @@ declare const ConfigKey: {
|
|
|
849
854
|
readonly property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput";
|
|
850
855
|
readonly property_extractorExtractionTimestamp: "@extractorExtractionTimestamp";
|
|
851
856
|
readonly property_isCaseSensitive: "@isCaseSensitive";
|
|
857
|
+
readonly property_isCollapsible: "@isCollapsible";
|
|
852
858
|
readonly property_isInfoOnly: "@isInfoOnly";
|
|
853
859
|
readonly property_isPublic: "@isPublic";
|
|
854
860
|
readonly property_isTemplate: "@isTemplate";
|
|
@@ -1901,6 +1907,7 @@ interface BitJson {
|
|
|
1901
1907
|
level: number;
|
|
1902
1908
|
toc: boolean;
|
|
1903
1909
|
progress: boolean;
|
|
1910
|
+
isCollapsible: boolean;
|
|
1904
1911
|
anchor: string;
|
|
1905
1912
|
reference: string | string[];
|
|
1906
1913
|
referenceEnd: string;
|
|
@@ -2537,6 +2544,7 @@ interface Bit {
|
|
|
2537
2544
|
level?: number;
|
|
2538
2545
|
toc?: Property;
|
|
2539
2546
|
progress?: Property;
|
|
2547
|
+
isCollapsible?: Property;
|
|
2540
2548
|
anchor?: string;
|
|
2541
2549
|
reference?: string;
|
|
2542
2550
|
referenceEnd?: string;
|
|
@@ -2911,6 +2919,8 @@ declare const NodeType: {
|
|
|
2911
2919
|
readonly internalPrintPdf: "internalPrintPdf";
|
|
2912
2920
|
readonly internalPrintPdfValue: "internalPrintPdfValue";
|
|
2913
2921
|
readonly isCaseSensitive: "isCaseSensitive";
|
|
2922
|
+
readonly isCollapsible: "isCollapsible";
|
|
2923
|
+
readonly isCollapsibleValue: "isCollapsibleValue";
|
|
2914
2924
|
readonly isCommented: "isCommented";
|
|
2915
2925
|
readonly isCorrect: "isCorrect";
|
|
2916
2926
|
readonly isEditable: "isEditable";
|
|
@@ -3830,6 +3840,7 @@ declare const CardSetConfigKey: {
|
|
|
3830
3840
|
readonly flashcard: "flashcard";
|
|
3831
3841
|
readonly flashcard1: "flashcard1";
|
|
3832
3842
|
readonly definitionList: "definitionList";
|
|
3843
|
+
readonly definitionListPlain: "definitionListPlain";
|
|
3833
3844
|
readonly elements: "elements";
|
|
3834
3845
|
readonly statements: "statements";
|
|
3835
3846
|
readonly quiz: "quiz";
|
|
@@ -4461,6 +4472,7 @@ declare class Builder extends BaseBuilder {
|
|
|
4461
4472
|
level?: number | string;
|
|
4462
4473
|
toc?: boolean;
|
|
4463
4474
|
progress?: boolean;
|
|
4475
|
+
isCollapsible?: boolean;
|
|
4464
4476
|
anchor?: string;
|
|
4465
4477
|
reference?: string;
|
|
4466
4478
|
referenceEnd?: string;
|
|
@@ -6425,6 +6437,65 @@ declare class FileWriter extends StreamWriter {
|
|
|
6425
6437
|
close(): Promise<void>;
|
|
6426
6438
|
}
|
|
6427
6439
|
|
|
6440
|
+
/**
|
|
6441
|
+
* Extract HTML tables and convert them into bitmark table bit-JSON.
|
|
6442
|
+
*
|
|
6443
|
+
* Produces an array of bare `BitJson`-shaped objects (`type` = `table-extended` or `table`) that
|
|
6444
|
+
* can be fed directly into the existing JSON → AST → output pipeline. Cell content is built as
|
|
6445
|
+
* `TextAst` (rich text nodes) directly; the downstream generators handle serialisation and
|
|
6446
|
+
* breakscaping.
|
|
6447
|
+
*
|
|
6448
|
+
* See PLAN-013 for the full specification.
|
|
6449
|
+
*/
|
|
6450
|
+
|
|
6451
|
+
type HtmlTableFormat = 'table' | 'table-extended';
|
|
6452
|
+
interface HtmlTableParseOptions {
|
|
6453
|
+
/** Output bit type. Default `table-extended` (lossless). `table` is lossy. */
|
|
6454
|
+
tableFormat?: HtmlTableFormat;
|
|
6455
|
+
/** Keep unmappable tags as literal text instead of unwrapping them. Default false. */
|
|
6456
|
+
keepUnknownTags?: boolean;
|
|
6457
|
+
/** Called with a human-readable message when information is lost (e.g. lossy `table` output). */
|
|
6458
|
+
onWarning?: (message: string) => void;
|
|
6459
|
+
}
|
|
6460
|
+
/** Loosely-typed table bit JSON (matches a subset of BitJson). */
|
|
6461
|
+
interface TableBitJson {
|
|
6462
|
+
type: HtmlTableFormat;
|
|
6463
|
+
format: 'bitmark++';
|
|
6464
|
+
caption?: TextAst;
|
|
6465
|
+
table: TableJson | TableExtendedJson;
|
|
6466
|
+
}
|
|
6467
|
+
declare class HtmlTableParser {
|
|
6468
|
+
private keepUnknownTags;
|
|
6469
|
+
/**
|
|
6470
|
+
* Parse an HTML string and return one table bit per top-level `<table>`.
|
|
6471
|
+
*/
|
|
6472
|
+
parse(html: string, options?: HtmlTableParseOptions): TableBitJson[];
|
|
6473
|
+
/** Collect every `<table>` element, NOT descending into nested tables. */
|
|
6474
|
+
private collectTopLevelTables;
|
|
6475
|
+
private tableToBit;
|
|
6476
|
+
private rowToCells;
|
|
6477
|
+
private cellToJson;
|
|
6478
|
+
private widthFromCell;
|
|
6479
|
+
private isLossyAsBasic;
|
|
6480
|
+
/**
|
|
6481
|
+
* Convert a cell/li's child nodes into block-level TextAst nodes (paragraphs, lists, images).
|
|
6482
|
+
*/
|
|
6483
|
+
private blockNodes;
|
|
6484
|
+
/** Convert child nodes to a flat list of inline TextNodes, applying the given marks. */
|
|
6485
|
+
private inlineNodes;
|
|
6486
|
+
private inlineFromElement;
|
|
6487
|
+
private inlineText;
|
|
6488
|
+
private serializeOpenTag;
|
|
6489
|
+
private isListTag;
|
|
6490
|
+
private listNode;
|
|
6491
|
+
private listType;
|
|
6492
|
+
private listItemNode;
|
|
6493
|
+
private taskItemNode;
|
|
6494
|
+
private imageNode;
|
|
6495
|
+
/** Trim leading/trailing whitespace from inline content (edges only). */
|
|
6496
|
+
private trimInline;
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6428
6499
|
/**
|
|
6429
6500
|
* Info options for the parser
|
|
6430
6501
|
*/
|
|
@@ -6600,6 +6671,48 @@ interface ExtractPlainTextOptions {
|
|
|
6600
6671
|
*/
|
|
6601
6672
|
inputFormat?: InputFormatType;
|
|
6602
6673
|
}
|
|
6674
|
+
/**
|
|
6675
|
+
* Options for {@link BitmarkParserGenerator.convertHtmlTable}
|
|
6676
|
+
*/
|
|
6677
|
+
interface ConvertHtmlTableOptions {
|
|
6678
|
+
/**
|
|
6679
|
+
* Force the input format, overriding auto-detection.
|
|
6680
|
+
* - `html`: input is HTML; extract tables and output bitmark/JSON/AST
|
|
6681
|
+
* - any other value: input is bitmark/JSON/AST; output HTML
|
|
6682
|
+
*/
|
|
6683
|
+
inputFormat?: InputFormatType;
|
|
6684
|
+
/**
|
|
6685
|
+
* Output format.
|
|
6686
|
+
* - HTML input: `bitmark` (default) | `json` | `ast` | `html` (re-emit / normalise)
|
|
6687
|
+
* - bitmark/JSON/AST input: `html` (default, and only valid value)
|
|
6688
|
+
*/
|
|
6689
|
+
outputFormat?: OutputType | 'html';
|
|
6690
|
+
/**
|
|
6691
|
+
* Bit type to emit when converting HTML to bits.
|
|
6692
|
+
* `table-extended` (default, lossless) or `table` (lossy: drops spans/scope/sections).
|
|
6693
|
+
*/
|
|
6694
|
+
tableFormat?: HtmlTableFormat;
|
|
6695
|
+
/**
|
|
6696
|
+
* Keep unmappable HTML tags as literal text instead of unwrapping them (HTML -> bits only).
|
|
6697
|
+
*/
|
|
6698
|
+
keepUnknownTags?: boolean;
|
|
6699
|
+
/**
|
|
6700
|
+
* Specify a file to write the output to
|
|
6701
|
+
*/
|
|
6702
|
+
outputFile?: string;
|
|
6703
|
+
/**
|
|
6704
|
+
* Options for the output file
|
|
6705
|
+
*/
|
|
6706
|
+
fileOptions?: FileOptions;
|
|
6707
|
+
/**
|
|
6708
|
+
* Options for bitmark generation (HTML -> bitmark)
|
|
6709
|
+
*/
|
|
6710
|
+
bitmarkOptions?: BitmarkOptions;
|
|
6711
|
+
/**
|
|
6712
|
+
* Options for JSON generation (HTML -> json)
|
|
6713
|
+
*/
|
|
6714
|
+
jsonOptions?: JsonOptions;
|
|
6715
|
+
}
|
|
6603
6716
|
/**
|
|
6604
6717
|
* Breakscape options
|
|
6605
6718
|
*/
|
|
@@ -6704,6 +6817,10 @@ declare const InputFormat: {
|
|
|
6704
6817
|
* Input is plain text
|
|
6705
6818
|
*/
|
|
6706
6819
|
readonly plainText: "plainText";
|
|
6820
|
+
/**
|
|
6821
|
+
* Input is HTML (used by convertHtmlTable)
|
|
6822
|
+
*/
|
|
6823
|
+
readonly html: "html";
|
|
6707
6824
|
};
|
|
6708
6825
|
type InputFormatType = EnumType<typeof InputFormat>;
|
|
6709
6826
|
/**
|
|
@@ -6852,6 +6969,28 @@ declare class BitmarkParserGenerator {
|
|
|
6852
6969
|
*/
|
|
6853
6970
|
convertText(input: string | unknown, options?: ConvertTextOptions): string | unknown | void;
|
|
6854
6971
|
extractPlainText(input: string | unknown, options?: ExtractPlainTextOptions): string;
|
|
6972
|
+
/**
|
|
6973
|
+
* Convert between HTML tables and bitmark tables.
|
|
6974
|
+
*
|
|
6975
|
+
* Direction is auto-detected (override with `options.inputFormat`):
|
|
6976
|
+
* - HTML input: every `<table>` is extracted and emitted as a `[.table-extended]` (or `[.table]`)
|
|
6977
|
+
* bit; output as bitmark (default), JSON, AST, or HTML (re-emit).
|
|
6978
|
+
* - bitmark / JSON / AST input: each `table` / `table-extended` bit is rendered as an HTML
|
|
6979
|
+
* `<table>` fragment.
|
|
6980
|
+
*
|
|
6981
|
+
* Cell content is reproduced verbatim except inline conversion to bitmark marks (bold, italic,
|
|
6982
|
+
* superscript, etc.), with lists and images mapped to their bitmark equivalents.
|
|
6983
|
+
*
|
|
6984
|
+
* @param input - HTML, bitmark, JSON or AST string; or a parsed JSON/AST value; or a file path.
|
|
6985
|
+
* @param options - the conversion options
|
|
6986
|
+
* @returns the converted output as a string (or object for JSON/AST), or void when writing a file
|
|
6987
|
+
* @throws Error if any error occurs
|
|
6988
|
+
*/
|
|
6989
|
+
convertHtmlTable(input: string | unknown, options?: ConvertHtmlTableOptions): string | unknown | void;
|
|
6990
|
+
/**
|
|
6991
|
+
* Write an HTML string to the configured output file, or return it.
|
|
6992
|
+
*/
|
|
6993
|
+
private outputHtml;
|
|
6855
6994
|
/**
|
|
6856
6995
|
* Breakscape bitmark text.
|
|
6857
6996
|
*
|
|
@@ -7114,4 +7253,39 @@ declare class JsonFileGenerator implements Generator<BitmarkAst> {
|
|
|
7114
7253
|
generateSync(_ast: BitmarkAst): void;
|
|
7115
7254
|
}
|
|
7116
7255
|
|
|
7117
|
-
|
|
7256
|
+
/**
|
|
7257
|
+
* Generate HTML `<table>` fragments from bitmark table bit-JSON.
|
|
7258
|
+
*
|
|
7259
|
+
* Consumes the JSON bit array (a string or parsed value), like {@link PlainTextGenerator}, and
|
|
7260
|
+
* renders each `table` / `table-extended` bit as a pretty-printed HTML `<table>` fragment. Cell
|
|
7261
|
+
* content (TextAst) is rendered back to inline/block HTML, mapping bitmark marks to inline tags.
|
|
7262
|
+
*
|
|
7263
|
+
* See PLAN-013 for the full specification.
|
|
7264
|
+
*/
|
|
7265
|
+
declare class HtmlTableGenerator {
|
|
7266
|
+
private readonly indentUnit;
|
|
7267
|
+
/**
|
|
7268
|
+
* Generate HTML table fragments from a string or JSON value.
|
|
7269
|
+
* @returns the concatenated `<table>` fragments, blank-line separated (empty string if none).
|
|
7270
|
+
*/
|
|
7271
|
+
generate(input: string | unknown): string;
|
|
7272
|
+
private collectBits;
|
|
7273
|
+
private renderTableBit;
|
|
7274
|
+
private toExtended;
|
|
7275
|
+
private renderSection;
|
|
7276
|
+
private renderCell;
|
|
7277
|
+
private asTextAst;
|
|
7278
|
+
private cellContentToHtml;
|
|
7279
|
+
private blockToHtml;
|
|
7280
|
+
private inlineToHtml;
|
|
7281
|
+
private inlineNodeToHtml;
|
|
7282
|
+
private wrapMarks;
|
|
7283
|
+
private listToHtml;
|
|
7284
|
+
private listTag;
|
|
7285
|
+
private listItemToHtml;
|
|
7286
|
+
private imageToHtml;
|
|
7287
|
+
private escapeText;
|
|
7288
|
+
private escapeAttr;
|
|
7289
|
+
}
|
|
7290
|
+
|
|
7291
|
+
export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AstWalkCallbacks, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type Bbox, type Bit, type BitJson, BitType, type BitTypeType, type BitWrapperJson, type BitmarkAst, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type Body, type BodyBitJson, type BodyBitsJson, type BodyPart, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, type BoundingBoxEntry, BoundingBoxIndex, type BreakscapeOptions, type BreakscapedString, Builder, type CardBit, type CardNode, CardSetVersion, type CardSetVersionType, type ChoiceJson, type CodeBlockTextNode, type CodeBlockTextNodeAttributes, type CommentMark, type ConvertHtmlTableOptions, type ConvertOptions, type ConvertTextOptions, type CreateAstOptions, type DefinitionListItemJson, type DocumentDownloadResourceJson, type DocumentDownloadResourceWrapperJson, type DocumentEmbedResourceJson, type DocumentEmbedResourceWrapperJson, type DocumentLinkResourceJson, type DocumentLinkResourceWrapperJson, type DocumentResourceJson, type DocumentResourceWrapperJson, type Example, type ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtraProperties, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type Footer, type FootnoteAttibutes, type FootnoteMark, type FromBitsOptions, type GapJson, type Generator, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, type HtmlTableFormat, HtmlTableGenerator, type HtmlTableParseOptions, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageSourceJson, type ImageTextNode, type ImageTextNodeAttributes, InfoFormat, type InfoFormatType, type InfoOptions, InfoType, type InfoTypeType, type IngredientJson, Input, InputFormat, type InputFormatType, type InputType, JsonFileGenerator, JsonGenerator, type JsonOptions, JsonParser, JsonStringGenerator, type LatexTextNode, type LatexTextNodeAttributes, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, type Node, type NodeInfo, NodeType, type NodeTypeType, Output, type OutputType, type PairJson, type ParserJson, type PersonJson, type UpgradeOptions as PrettifyOptions, type PronunciationTableCellJson, type PronunciationTableJson, type Property, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, type RefMark, type RefMarkAttibutes, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceTypeType, type ResourceWrapperJson, type ResponseJson, type SectionTextNode, type SelectJson, type SelectOptionJson, type ServingsJson, type StatementJson, type StillImageFilmEmbedResourceJson, type StillImageFilmEmbedResourceWrapperJson, type StillImageFilmLinkResourceJson, type StillImageFilmLinkResourceWrapperJson, type StillImageFilmResourceJson, type StillImageFilmResourceWrapperJson, StreamWriter, StringWriter, type SymbolMark, type TableCellJson, type TableExtendedJson, type TableJson, type TableRowJson, type TableSectionJson, type TaskItemTextNode, type TaskItemTextNodeAttributes, type TechnicalTermJson, type JsonText as Text, type TextAndIconJson, type TextAst, type TextJsonOptions, type TextMark, type TextMarkAttibutes, TextMarkType, type TextMarkTypeType, type TextNode, type TextNodeAttibutes, TextNodeType, type TextNodeTypeType, type UnbreakscapeOptions, type UpgradeOptions, type VideoEmbedResourceJson, type VideoEmbedResourceWrapperJson, type VideoLinkResourceJson, type VideoLinkResourceWrapperJson, type VideoResourceJson, type VideoResourceWrapperJson, type WebsiteLinkResourceJson, type WebsiteLinkResourceWrapperJson, type Writer, type XRefMark, type XRefMarkAttibutes, parse as bitmarkTextParse };
|
package/dist/index.d.ts
CHANGED
|
@@ -221,6 +221,7 @@ declare const BitType: {
|
|
|
221
221
|
readonly dangerAlt: "danger-alt";
|
|
222
222
|
readonly dangerCollapsible: "danger-collapsible";
|
|
223
223
|
readonly definitionList: "definition-list";
|
|
224
|
+
readonly definitionListCollapsible: "definition-list-collapsible";
|
|
224
225
|
readonly definitionTerm: "definition-term";
|
|
225
226
|
readonly deleted: "deleted";
|
|
226
227
|
readonly details: "details";
|
|
@@ -501,6 +502,8 @@ declare const BitType: {
|
|
|
501
502
|
readonly smartStandardArticleNonNormativeCollapsible: "smart-standard-article-non-normative-collapsible";
|
|
502
503
|
readonly smartStandardArticleNormative: "smart-standard-article-normative";
|
|
503
504
|
readonly smartStandardArticleNormativeCollapsible: "smart-standard-article-normative-collapsible";
|
|
505
|
+
readonly smartStandardDefinitionListNonNormative: "smart-standard-definition-list-non-normative";
|
|
506
|
+
readonly smartStandardDefinitionListNormative: "smart-standard-definition-list-normative";
|
|
504
507
|
readonly smartStandardExampleNonNormative: "smart-standard-example-non-normative";
|
|
505
508
|
readonly smartStandardExampleNonNormativeCollapsible: "smart-standard-example-non-normative-collapsible";
|
|
506
509
|
readonly smartStandardExampleNormative: "smart-standard-example-normative";
|
|
@@ -551,6 +554,8 @@ declare const BitType: {
|
|
|
551
554
|
readonly smartStandardTableNormativeCollapsible: "smart-standard-table-normative-collapsible";
|
|
552
555
|
readonly standardArticleNonNormative: "standard-article-non-normative";
|
|
553
556
|
readonly standardArticleNormative: "standard-article-normative";
|
|
557
|
+
readonly standardDefinitionListNonNormative: "standard-definition-list-non-normative";
|
|
558
|
+
readonly standardDefinitionListNormative: "standard-definition-list-normative";
|
|
554
559
|
readonly standardExampleNonNormative: "standard-example-non-normative";
|
|
555
560
|
readonly standardExampleNormative: "standard-example-normative";
|
|
556
561
|
readonly standardImageFigureNonNormative: "standard-image-figure-non-normative";
|
|
@@ -849,6 +854,7 @@ declare const ConfigKey: {
|
|
|
849
854
|
readonly property_enforceUpdateOverUserInput: "@enforceUpdateOverUserInput";
|
|
850
855
|
readonly property_extractorExtractionTimestamp: "@extractorExtractionTimestamp";
|
|
851
856
|
readonly property_isCaseSensitive: "@isCaseSensitive";
|
|
857
|
+
readonly property_isCollapsible: "@isCollapsible";
|
|
852
858
|
readonly property_isInfoOnly: "@isInfoOnly";
|
|
853
859
|
readonly property_isPublic: "@isPublic";
|
|
854
860
|
readonly property_isTemplate: "@isTemplate";
|
|
@@ -1901,6 +1907,7 @@ interface BitJson {
|
|
|
1901
1907
|
level: number;
|
|
1902
1908
|
toc: boolean;
|
|
1903
1909
|
progress: boolean;
|
|
1910
|
+
isCollapsible: boolean;
|
|
1904
1911
|
anchor: string;
|
|
1905
1912
|
reference: string | string[];
|
|
1906
1913
|
referenceEnd: string;
|
|
@@ -2537,6 +2544,7 @@ interface Bit {
|
|
|
2537
2544
|
level?: number;
|
|
2538
2545
|
toc?: Property;
|
|
2539
2546
|
progress?: Property;
|
|
2547
|
+
isCollapsible?: Property;
|
|
2540
2548
|
anchor?: string;
|
|
2541
2549
|
reference?: string;
|
|
2542
2550
|
referenceEnd?: string;
|
|
@@ -2911,6 +2919,8 @@ declare const NodeType: {
|
|
|
2911
2919
|
readonly internalPrintPdf: "internalPrintPdf";
|
|
2912
2920
|
readonly internalPrintPdfValue: "internalPrintPdfValue";
|
|
2913
2921
|
readonly isCaseSensitive: "isCaseSensitive";
|
|
2922
|
+
readonly isCollapsible: "isCollapsible";
|
|
2923
|
+
readonly isCollapsibleValue: "isCollapsibleValue";
|
|
2914
2924
|
readonly isCommented: "isCommented";
|
|
2915
2925
|
readonly isCorrect: "isCorrect";
|
|
2916
2926
|
readonly isEditable: "isEditable";
|
|
@@ -3830,6 +3840,7 @@ declare const CardSetConfigKey: {
|
|
|
3830
3840
|
readonly flashcard: "flashcard";
|
|
3831
3841
|
readonly flashcard1: "flashcard1";
|
|
3832
3842
|
readonly definitionList: "definitionList";
|
|
3843
|
+
readonly definitionListPlain: "definitionListPlain";
|
|
3833
3844
|
readonly elements: "elements";
|
|
3834
3845
|
readonly statements: "statements";
|
|
3835
3846
|
readonly quiz: "quiz";
|
|
@@ -4461,6 +4472,7 @@ declare class Builder extends BaseBuilder {
|
|
|
4461
4472
|
level?: number | string;
|
|
4462
4473
|
toc?: boolean;
|
|
4463
4474
|
progress?: boolean;
|
|
4475
|
+
isCollapsible?: boolean;
|
|
4464
4476
|
anchor?: string;
|
|
4465
4477
|
reference?: string;
|
|
4466
4478
|
referenceEnd?: string;
|
|
@@ -6425,6 +6437,65 @@ declare class FileWriter extends StreamWriter {
|
|
|
6425
6437
|
close(): Promise<void>;
|
|
6426
6438
|
}
|
|
6427
6439
|
|
|
6440
|
+
/**
|
|
6441
|
+
* Extract HTML tables and convert them into bitmark table bit-JSON.
|
|
6442
|
+
*
|
|
6443
|
+
* Produces an array of bare `BitJson`-shaped objects (`type` = `table-extended` or `table`) that
|
|
6444
|
+
* can be fed directly into the existing JSON → AST → output pipeline. Cell content is built as
|
|
6445
|
+
* `TextAst` (rich text nodes) directly; the downstream generators handle serialisation and
|
|
6446
|
+
* breakscaping.
|
|
6447
|
+
*
|
|
6448
|
+
* See PLAN-013 for the full specification.
|
|
6449
|
+
*/
|
|
6450
|
+
|
|
6451
|
+
type HtmlTableFormat = 'table' | 'table-extended';
|
|
6452
|
+
interface HtmlTableParseOptions {
|
|
6453
|
+
/** Output bit type. Default `table-extended` (lossless). `table` is lossy. */
|
|
6454
|
+
tableFormat?: HtmlTableFormat;
|
|
6455
|
+
/** Keep unmappable tags as literal text instead of unwrapping them. Default false. */
|
|
6456
|
+
keepUnknownTags?: boolean;
|
|
6457
|
+
/** Called with a human-readable message when information is lost (e.g. lossy `table` output). */
|
|
6458
|
+
onWarning?: (message: string) => void;
|
|
6459
|
+
}
|
|
6460
|
+
/** Loosely-typed table bit JSON (matches a subset of BitJson). */
|
|
6461
|
+
interface TableBitJson {
|
|
6462
|
+
type: HtmlTableFormat;
|
|
6463
|
+
format: 'bitmark++';
|
|
6464
|
+
caption?: TextAst;
|
|
6465
|
+
table: TableJson | TableExtendedJson;
|
|
6466
|
+
}
|
|
6467
|
+
declare class HtmlTableParser {
|
|
6468
|
+
private keepUnknownTags;
|
|
6469
|
+
/**
|
|
6470
|
+
* Parse an HTML string and return one table bit per top-level `<table>`.
|
|
6471
|
+
*/
|
|
6472
|
+
parse(html: string, options?: HtmlTableParseOptions): TableBitJson[];
|
|
6473
|
+
/** Collect every `<table>` element, NOT descending into nested tables. */
|
|
6474
|
+
private collectTopLevelTables;
|
|
6475
|
+
private tableToBit;
|
|
6476
|
+
private rowToCells;
|
|
6477
|
+
private cellToJson;
|
|
6478
|
+
private widthFromCell;
|
|
6479
|
+
private isLossyAsBasic;
|
|
6480
|
+
/**
|
|
6481
|
+
* Convert a cell/li's child nodes into block-level TextAst nodes (paragraphs, lists, images).
|
|
6482
|
+
*/
|
|
6483
|
+
private blockNodes;
|
|
6484
|
+
/** Convert child nodes to a flat list of inline TextNodes, applying the given marks. */
|
|
6485
|
+
private inlineNodes;
|
|
6486
|
+
private inlineFromElement;
|
|
6487
|
+
private inlineText;
|
|
6488
|
+
private serializeOpenTag;
|
|
6489
|
+
private isListTag;
|
|
6490
|
+
private listNode;
|
|
6491
|
+
private listType;
|
|
6492
|
+
private listItemNode;
|
|
6493
|
+
private taskItemNode;
|
|
6494
|
+
private imageNode;
|
|
6495
|
+
/** Trim leading/trailing whitespace from inline content (edges only). */
|
|
6496
|
+
private trimInline;
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6428
6499
|
/**
|
|
6429
6500
|
* Info options for the parser
|
|
6430
6501
|
*/
|
|
@@ -6600,6 +6671,48 @@ interface ExtractPlainTextOptions {
|
|
|
6600
6671
|
*/
|
|
6601
6672
|
inputFormat?: InputFormatType;
|
|
6602
6673
|
}
|
|
6674
|
+
/**
|
|
6675
|
+
* Options for {@link BitmarkParserGenerator.convertHtmlTable}
|
|
6676
|
+
*/
|
|
6677
|
+
interface ConvertHtmlTableOptions {
|
|
6678
|
+
/**
|
|
6679
|
+
* Force the input format, overriding auto-detection.
|
|
6680
|
+
* - `html`: input is HTML; extract tables and output bitmark/JSON/AST
|
|
6681
|
+
* - any other value: input is bitmark/JSON/AST; output HTML
|
|
6682
|
+
*/
|
|
6683
|
+
inputFormat?: InputFormatType;
|
|
6684
|
+
/**
|
|
6685
|
+
* Output format.
|
|
6686
|
+
* - HTML input: `bitmark` (default) | `json` | `ast` | `html` (re-emit / normalise)
|
|
6687
|
+
* - bitmark/JSON/AST input: `html` (default, and only valid value)
|
|
6688
|
+
*/
|
|
6689
|
+
outputFormat?: OutputType | 'html';
|
|
6690
|
+
/**
|
|
6691
|
+
* Bit type to emit when converting HTML to bits.
|
|
6692
|
+
* `table-extended` (default, lossless) or `table` (lossy: drops spans/scope/sections).
|
|
6693
|
+
*/
|
|
6694
|
+
tableFormat?: HtmlTableFormat;
|
|
6695
|
+
/**
|
|
6696
|
+
* Keep unmappable HTML tags as literal text instead of unwrapping them (HTML -> bits only).
|
|
6697
|
+
*/
|
|
6698
|
+
keepUnknownTags?: boolean;
|
|
6699
|
+
/**
|
|
6700
|
+
* Specify a file to write the output to
|
|
6701
|
+
*/
|
|
6702
|
+
outputFile?: string;
|
|
6703
|
+
/**
|
|
6704
|
+
* Options for the output file
|
|
6705
|
+
*/
|
|
6706
|
+
fileOptions?: FileOptions;
|
|
6707
|
+
/**
|
|
6708
|
+
* Options for bitmark generation (HTML -> bitmark)
|
|
6709
|
+
*/
|
|
6710
|
+
bitmarkOptions?: BitmarkOptions;
|
|
6711
|
+
/**
|
|
6712
|
+
* Options for JSON generation (HTML -> json)
|
|
6713
|
+
*/
|
|
6714
|
+
jsonOptions?: JsonOptions;
|
|
6715
|
+
}
|
|
6603
6716
|
/**
|
|
6604
6717
|
* Breakscape options
|
|
6605
6718
|
*/
|
|
@@ -6704,6 +6817,10 @@ declare const InputFormat: {
|
|
|
6704
6817
|
* Input is plain text
|
|
6705
6818
|
*/
|
|
6706
6819
|
readonly plainText: "plainText";
|
|
6820
|
+
/**
|
|
6821
|
+
* Input is HTML (used by convertHtmlTable)
|
|
6822
|
+
*/
|
|
6823
|
+
readonly html: "html";
|
|
6707
6824
|
};
|
|
6708
6825
|
type InputFormatType = EnumType<typeof InputFormat>;
|
|
6709
6826
|
/**
|
|
@@ -6852,6 +6969,28 @@ declare class BitmarkParserGenerator {
|
|
|
6852
6969
|
*/
|
|
6853
6970
|
convertText(input: string | unknown, options?: ConvertTextOptions): string | unknown | void;
|
|
6854
6971
|
extractPlainText(input: string | unknown, options?: ExtractPlainTextOptions): string;
|
|
6972
|
+
/**
|
|
6973
|
+
* Convert between HTML tables and bitmark tables.
|
|
6974
|
+
*
|
|
6975
|
+
* Direction is auto-detected (override with `options.inputFormat`):
|
|
6976
|
+
* - HTML input: every `<table>` is extracted and emitted as a `[.table-extended]` (or `[.table]`)
|
|
6977
|
+
* bit; output as bitmark (default), JSON, AST, or HTML (re-emit).
|
|
6978
|
+
* - bitmark / JSON / AST input: each `table` / `table-extended` bit is rendered as an HTML
|
|
6979
|
+
* `<table>` fragment.
|
|
6980
|
+
*
|
|
6981
|
+
* Cell content is reproduced verbatim except inline conversion to bitmark marks (bold, italic,
|
|
6982
|
+
* superscript, etc.), with lists and images mapped to their bitmark equivalents.
|
|
6983
|
+
*
|
|
6984
|
+
* @param input - HTML, bitmark, JSON or AST string; or a parsed JSON/AST value; or a file path.
|
|
6985
|
+
* @param options - the conversion options
|
|
6986
|
+
* @returns the converted output as a string (or object for JSON/AST), or void when writing a file
|
|
6987
|
+
* @throws Error if any error occurs
|
|
6988
|
+
*/
|
|
6989
|
+
convertHtmlTable(input: string | unknown, options?: ConvertHtmlTableOptions): string | unknown | void;
|
|
6990
|
+
/**
|
|
6991
|
+
* Write an HTML string to the configured output file, or return it.
|
|
6992
|
+
*/
|
|
6993
|
+
private outputHtml;
|
|
6855
6994
|
/**
|
|
6856
6995
|
* Breakscape bitmark text.
|
|
6857
6996
|
*
|
|
@@ -7114,4 +7253,39 @@ declare class JsonFileGenerator implements Generator<BitmarkAst> {
|
|
|
7114
7253
|
generateSync(_ast: BitmarkAst): void;
|
|
7115
7254
|
}
|
|
7116
7255
|
|
|
7117
|
-
|
|
7256
|
+
/**
|
|
7257
|
+
* Generate HTML `<table>` fragments from bitmark table bit-JSON.
|
|
7258
|
+
*
|
|
7259
|
+
* Consumes the JSON bit array (a string or parsed value), like {@link PlainTextGenerator}, and
|
|
7260
|
+
* renders each `table` / `table-extended` bit as a pretty-printed HTML `<table>` fragment. Cell
|
|
7261
|
+
* content (TextAst) is rendered back to inline/block HTML, mapping bitmark marks to inline tags.
|
|
7262
|
+
*
|
|
7263
|
+
* See PLAN-013 for the full specification.
|
|
7264
|
+
*/
|
|
7265
|
+
declare class HtmlTableGenerator {
|
|
7266
|
+
private readonly indentUnit;
|
|
7267
|
+
/**
|
|
7268
|
+
* Generate HTML table fragments from a string or JSON value.
|
|
7269
|
+
* @returns the concatenated `<table>` fragments, blank-line separated (empty string if none).
|
|
7270
|
+
*/
|
|
7271
|
+
generate(input: string | unknown): string;
|
|
7272
|
+
private collectBits;
|
|
7273
|
+
private renderTableBit;
|
|
7274
|
+
private toExtended;
|
|
7275
|
+
private renderSection;
|
|
7276
|
+
private renderCell;
|
|
7277
|
+
private asTextAst;
|
|
7278
|
+
private cellContentToHtml;
|
|
7279
|
+
private blockToHtml;
|
|
7280
|
+
private inlineToHtml;
|
|
7281
|
+
private inlineNodeToHtml;
|
|
7282
|
+
private wrapMarks;
|
|
7283
|
+
private listToHtml;
|
|
7284
|
+
private listTag;
|
|
7285
|
+
private listItemToHtml;
|
|
7286
|
+
private imageToHtml;
|
|
7287
|
+
private escapeText;
|
|
7288
|
+
private escapeAttr;
|
|
7289
|
+
}
|
|
7290
|
+
|
|
7291
|
+
export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AstWalkCallbacks, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type Bbox, type Bit, type BitJson, BitType, type BitTypeType, type BitWrapperJson, type BitmarkAst, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type Body, type BodyBitJson, type BodyBitsJson, type BodyPart, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, type BoundingBoxEntry, BoundingBoxIndex, type BreakscapeOptions, type BreakscapedString, Builder, type CardBit, type CardNode, CardSetVersion, type CardSetVersionType, type ChoiceJson, type CodeBlockTextNode, type CodeBlockTextNodeAttributes, type CommentMark, type ConvertHtmlTableOptions, type ConvertOptions, type ConvertTextOptions, type CreateAstOptions, type DefinitionListItemJson, type DocumentDownloadResourceJson, type DocumentDownloadResourceWrapperJson, type DocumentEmbedResourceJson, type DocumentEmbedResourceWrapperJson, type DocumentLinkResourceJson, type DocumentLinkResourceWrapperJson, type DocumentResourceJson, type DocumentResourceWrapperJson, type Example, type ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtraProperties, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type Footer, type FootnoteAttibutes, type FootnoteMark, type FromBitsOptions, type GapJson, type Generator, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, type HtmlTableFormat, HtmlTableGenerator, type HtmlTableParseOptions, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageSourceJson, type ImageTextNode, type ImageTextNodeAttributes, InfoFormat, type InfoFormatType, type InfoOptions, InfoType, type InfoTypeType, type IngredientJson, Input, InputFormat, type InputFormatType, type InputType, JsonFileGenerator, JsonGenerator, type JsonOptions, JsonParser, JsonStringGenerator, type LatexTextNode, type LatexTextNodeAttributes, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, type Node, type NodeInfo, NodeType, type NodeTypeType, Output, type OutputType, type PairJson, type ParserJson, type PersonJson, type UpgradeOptions as PrettifyOptions, type PronunciationTableCellJson, type PronunciationTableJson, type Property, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, type RefMark, type RefMarkAttibutes, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceTypeType, type ResourceWrapperJson, type ResponseJson, type SectionTextNode, type SelectJson, type SelectOptionJson, type ServingsJson, type StatementJson, type StillImageFilmEmbedResourceJson, type StillImageFilmEmbedResourceWrapperJson, type StillImageFilmLinkResourceJson, type StillImageFilmLinkResourceWrapperJson, type StillImageFilmResourceJson, type StillImageFilmResourceWrapperJson, StreamWriter, StringWriter, type SymbolMark, type TableCellJson, type TableExtendedJson, type TableJson, type TableRowJson, type TableSectionJson, type TaskItemTextNode, type TaskItemTextNodeAttributes, type TechnicalTermJson, type JsonText as Text, type TextAndIconJson, type TextAst, type TextJsonOptions, type TextMark, type TextMarkAttibutes, TextMarkType, type TextMarkTypeType, type TextNode, type TextNodeAttibutes, TextNodeType, type TextNodeTypeType, type UnbreakscapeOptions, type UpgradeOptions, type VideoEmbedResourceJson, type VideoEmbedResourceWrapperJson, type VideoLinkResourceJson, type VideoLinkResourceWrapperJson, type VideoResourceJson, type VideoResourceWrapperJson, type WebsiteLinkResourceJson, type WebsiteLinkResourceWrapperJson, type Writer, type XRefMark, type XRefMarkAttibutes, parse as bitmarkTextParse };
|