@gmb/bitmark-parser 6.1.4 → 6.3.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/README.md +129 -46
- package/dist/browser/bitmark-parser.min.js +4 -4
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +144 -174
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +13834 -256
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +13834 -256
- package/dist/browser/esm/index.js +141 -170
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/esm/worker-entry.js.map +1 -1
- package/dist/index.cjs +75 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15392 -218
- package/dist/index.d.ts +15392 -218
- package/dist/index.js +72 -42
- package/dist/index.js.map +1 -1
- package/dist/legacy.cjs +40 -23
- package/dist/legacy.cjs.map +1 -1
- package/dist/legacy.d.cts +33 -14
- package/dist/legacy.d.ts +33 -14
- package/dist/legacy.js +40 -23
- package/dist/legacy.js.map +1 -1
- package/package.json +12 -8
- package/wasm/bitmark_wasm.d.ts +31 -53
- package/wasm/bitmark_wasm.js +115 -209
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -4
- package/wasm/package.json +1 -1
package/dist/legacy.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
type EnumType<T> = T[keyof T];
|
|
2
3
|
/** Input type enumeration */
|
|
3
4
|
declare const Input: {
|
|
@@ -76,21 +77,32 @@ interface FileOptions {
|
|
|
76
77
|
}
|
|
77
78
|
/** Options for bitmark generation */
|
|
78
79
|
interface BitmarkOptions {
|
|
79
|
-
|
|
80
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
81
|
+
explicitTextFormat?: false;
|
|
80
82
|
prettifyJson?: boolean | number;
|
|
81
|
-
|
|
83
|
+
/** bitmark v3 only — card set version `1` throws `LegacyUnsupportedError` at runtime. */
|
|
84
|
+
cardSetVersion?: typeof CardSetVersion.v2;
|
|
82
85
|
spacesAroundValues?: number | boolean;
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
87
|
+
debugGenerationInline?: false;
|
|
88
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
89
|
+
noBreakscaping?: false;
|
|
85
90
|
}
|
|
86
91
|
/** Options for JSON generation */
|
|
87
92
|
interface JsonOptions {
|
|
88
93
|
enableWarnings?: boolean | number;
|
|
89
94
|
prettify?: boolean | number;
|
|
90
95
|
stringify?: boolean;
|
|
91
|
-
|
|
96
|
+
/** bitmark v3 only — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
97
|
+
textAsPlainText?: false;
|
|
98
|
+
/**
|
|
99
|
+
* Exclude unknown properties from the JSON output (default: `false` —
|
|
100
|
+
* unknown properties are included, as bpg). The parser's warning text
|
|
101
|
+
* references the new API's inverse flag (`includeUnknownProperties`).
|
|
102
|
+
*/
|
|
92
103
|
excludeUnknownProperties?: boolean;
|
|
93
|
-
|
|
104
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
105
|
+
debugGenerationInline?: false;
|
|
94
106
|
}
|
|
95
107
|
/** Options for bitmark text JSON generation */
|
|
96
108
|
interface TextJsonOptions {
|
|
@@ -105,7 +117,8 @@ interface InfoOptions {
|
|
|
105
117
|
}
|
|
106
118
|
/** Conversion options for bitmark / JSON conversion */
|
|
107
119
|
interface ConvertOptions {
|
|
108
|
-
|
|
120
|
+
/** bitmark v3 only — version `2` throws `LegacyUnsupportedError` at runtime. */
|
|
121
|
+
bitmarkVersion?: typeof BitmarkVersion.v3;
|
|
109
122
|
bitmarkParserType?: BitmarkParserTypeType;
|
|
110
123
|
inputFormat?: InputType;
|
|
111
124
|
outputFormat?: OutputType;
|
|
@@ -116,7 +129,8 @@ interface ConvertOptions {
|
|
|
116
129
|
}
|
|
117
130
|
/** Prettify options for bitmark / JSON prettify / validate */
|
|
118
131
|
interface UpgradeOptions {
|
|
119
|
-
|
|
132
|
+
/** bitmark v3 only — version `2` throws `LegacyUnsupportedError` at runtime. */
|
|
133
|
+
bitmarkVersion?: typeof BitmarkVersion.v3;
|
|
120
134
|
bitmarkParserType?: BitmarkParserTypeType;
|
|
121
135
|
inputFormat?: InputType;
|
|
122
136
|
outputFile?: string;
|
|
@@ -146,7 +160,8 @@ interface ConvertHtmlTableOptions {
|
|
|
146
160
|
outputFormat?: OutputType | "html";
|
|
147
161
|
tableFormat?: string;
|
|
148
162
|
keepUnknownTags?: boolean;
|
|
149
|
-
|
|
163
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
164
|
+
noBreakscaping?: false;
|
|
150
165
|
outputFile?: string;
|
|
151
166
|
fileOptions?: FileOptions;
|
|
152
167
|
bitmarkOptions?: BitmarkOptions;
|
|
@@ -342,10 +357,14 @@ declare class Builder {
|
|
|
342
357
|
* NOTE (documented divergences from bpg):
|
|
343
358
|
* - the return value is bit JSON, not bpg's internal AST node model;
|
|
344
359
|
* - `resourceType` (an inference hint in bpg) is not carried into the
|
|
345
|
-
* JSON — the attached `resource` object is authoritative
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
360
|
+
* JSON — the attached `resource` object is authoritative.
|
|
361
|
+
*
|
|
362
|
+
* `resources` follows bpg's JsonGenerator routing: on a bit whose config
|
|
363
|
+
* maps a repeatable resource tag group onto a collection key (e.g.
|
|
364
|
+
* `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
|
|
365
|
+
* matching-type entries land under that key; on every other bit the first
|
|
366
|
+
* entry becomes the canonical single `resource` (as bpg: "if there is
|
|
367
|
+
* more than one resource, use the first one").
|
|
349
368
|
*/
|
|
350
369
|
buildBit(data: Record<string, unknown>, _options?: BuildBitOptions): Record<string, unknown>;
|
|
351
370
|
/**
|
|
@@ -1565,4 +1584,4 @@ interface BitWrapperJson {
|
|
|
1565
1584
|
parser?: ParserJson;
|
|
1566
1585
|
}
|
|
1567
1586
|
|
|
1568
|
-
export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type BaseBodyBitJson, type BaseResourceJson, type BitJson, BitType, type BitTypeType, type BitWrapperJson, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type BodyBitJson, type BodyBitsJson, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, BoundingBoxIndex, type BreakscapeOptions, type BuildBitOptions, Builder, 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 ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtractPlainTextOptions, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type FootnoteAttibutes, type FootnoteMark, type GapJson, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, HtmlTableGenerator, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageResponsiveResourceJson, type ImageResponsiveResourceWrapperJson, 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 JsonText, type LatexTextNode, type LatexTextNodeAttributes, type LegacyPseudoAst, LegacyUnsupportedError, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, NodeType, Output, type OutputType, type PairJson, type ParserError, type ParserInfo, type ParserJson, type ParserLocation, type PersonJson, type PronunciationTableCellJson, type PronunciationTableJson, 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 SymbolMarkAttibutes, type TableCellJson, type TableExtendedJson, type TableJson, type TableRowJson, type TableSectionJson, type TaskItemTextNode, type TaskItemTextNodeAttributes, type TechnicalTermJson, type TextAndIconJson, type TextAst, type TextFormatType, type TextJsonOptions, TextLocation, type TextLocationType, 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 XRefMark, type XRefMarkAttibutes, bitmarkTextParse, isPseudoAst };
|
|
1587
|
+
export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type BaseBodyBitJson, type BaseResourceJson, type BitJson, BitType, type BitTypeType, type BitWrapperJson, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type BodyBitJson, type BodyBitsJson, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, BoundingBoxIndex, type BreakscapeOptions, type BuildBitOptions, Builder, 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 ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtractPlainTextOptions, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type FootnoteAttibutes, type FootnoteMark, type GapJson, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, HtmlTableGenerator, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageResponsiveResourceJson, type ImageResponsiveResourceWrapperJson, 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 JsonText, type LatexTextNode, type LatexTextNodeAttributes, type LegacyPseudoAst, LegacyUnsupportedError, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, NodeType, Output, type OutputType, type PairJson, type ParserError, type ParserInfo, type ParserJson, type ParserLocation, type PersonJson, type PronunciationTableCellJson, type PronunciationTableJson, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, type RefMark, type RefMarkAttibutes, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceMethod, 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 SymbolMarkAttibutes, 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 TextFormatType, type TextJsonOptions, TextLocation, type TextLocationType, 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 XRefMark, type XRefMarkAttibutes, bitmarkTextParse, isPseudoAst };
|
package/dist/legacy.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
type EnumType<T> = T[keyof T];
|
|
2
3
|
/** Input type enumeration */
|
|
3
4
|
declare const Input: {
|
|
@@ -76,21 +77,32 @@ interface FileOptions {
|
|
|
76
77
|
}
|
|
77
78
|
/** Options for bitmark generation */
|
|
78
79
|
interface BitmarkOptions {
|
|
79
|
-
|
|
80
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
81
|
+
explicitTextFormat?: false;
|
|
80
82
|
prettifyJson?: boolean | number;
|
|
81
|
-
|
|
83
|
+
/** bitmark v3 only — card set version `1` throws `LegacyUnsupportedError` at runtime. */
|
|
84
|
+
cardSetVersion?: typeof CardSetVersion.v2;
|
|
82
85
|
spacesAroundValues?: number | boolean;
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
87
|
+
debugGenerationInline?: false;
|
|
88
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
89
|
+
noBreakscaping?: false;
|
|
85
90
|
}
|
|
86
91
|
/** Options for JSON generation */
|
|
87
92
|
interface JsonOptions {
|
|
88
93
|
enableWarnings?: boolean | number;
|
|
89
94
|
prettify?: boolean | number;
|
|
90
95
|
stringify?: boolean;
|
|
91
|
-
|
|
96
|
+
/** bitmark v3 only — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
97
|
+
textAsPlainText?: false;
|
|
98
|
+
/**
|
|
99
|
+
* Exclude unknown properties from the JSON output (default: `false` —
|
|
100
|
+
* unknown properties are included, as bpg). The parser's warning text
|
|
101
|
+
* references the new API's inverse flag (`includeUnknownProperties`).
|
|
102
|
+
*/
|
|
92
103
|
excludeUnknownProperties?: boolean;
|
|
93
|
-
|
|
104
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
105
|
+
debugGenerationInline?: false;
|
|
94
106
|
}
|
|
95
107
|
/** Options for bitmark text JSON generation */
|
|
96
108
|
interface TextJsonOptions {
|
|
@@ -105,7 +117,8 @@ interface InfoOptions {
|
|
|
105
117
|
}
|
|
106
118
|
/** Conversion options for bitmark / JSON conversion */
|
|
107
119
|
interface ConvertOptions {
|
|
108
|
-
|
|
120
|
+
/** bitmark v3 only — version `2` throws `LegacyUnsupportedError` at runtime. */
|
|
121
|
+
bitmarkVersion?: typeof BitmarkVersion.v3;
|
|
109
122
|
bitmarkParserType?: BitmarkParserTypeType;
|
|
110
123
|
inputFormat?: InputType;
|
|
111
124
|
outputFormat?: OutputType;
|
|
@@ -116,7 +129,8 @@ interface ConvertOptions {
|
|
|
116
129
|
}
|
|
117
130
|
/** Prettify options for bitmark / JSON prettify / validate */
|
|
118
131
|
interface UpgradeOptions {
|
|
119
|
-
|
|
132
|
+
/** bitmark v3 only — version `2` throws `LegacyUnsupportedError` at runtime. */
|
|
133
|
+
bitmarkVersion?: typeof BitmarkVersion.v3;
|
|
120
134
|
bitmarkParserType?: BitmarkParserTypeType;
|
|
121
135
|
inputFormat?: InputType;
|
|
122
136
|
outputFile?: string;
|
|
@@ -146,7 +160,8 @@ interface ConvertHtmlTableOptions {
|
|
|
146
160
|
outputFormat?: OutputType | "html";
|
|
147
161
|
tableFormat?: string;
|
|
148
162
|
keepUnknownTags?: boolean;
|
|
149
|
-
|
|
163
|
+
/** Not supported — `true` throws `LegacyUnsupportedError` at runtime. */
|
|
164
|
+
noBreakscaping?: false;
|
|
150
165
|
outputFile?: string;
|
|
151
166
|
fileOptions?: FileOptions;
|
|
152
167
|
bitmarkOptions?: BitmarkOptions;
|
|
@@ -342,10 +357,14 @@ declare class Builder {
|
|
|
342
357
|
* NOTE (documented divergences from bpg):
|
|
343
358
|
* - the return value is bit JSON, not bpg's internal AST node model;
|
|
344
359
|
* - `resourceType` (an inference hint in bpg) is not carried into the
|
|
345
|
-
* JSON — the attached `resource` object is authoritative
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
360
|
+
* JSON — the attached `resource` object is authoritative.
|
|
361
|
+
*
|
|
362
|
+
* `resources` follows bpg's JsonGenerator routing: on a bit whose config
|
|
363
|
+
* maps a repeatable resource tag group onto a collection key (e.g.
|
|
364
|
+
* `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
|
|
365
|
+
* matching-type entries land under that key; on every other bit the first
|
|
366
|
+
* entry becomes the canonical single `resource` (as bpg: "if there is
|
|
367
|
+
* more than one resource, use the first one").
|
|
349
368
|
*/
|
|
350
369
|
buildBit(data: Record<string, unknown>, _options?: BuildBitOptions): Record<string, unknown>;
|
|
351
370
|
/**
|
|
@@ -1565,4 +1584,4 @@ interface BitWrapperJson {
|
|
|
1565
1584
|
parser?: ParserJson;
|
|
1566
1585
|
}
|
|
1567
1586
|
|
|
1568
|
-
export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type BaseBodyBitJson, type BaseResourceJson, type BitJson, BitType, type BitTypeType, type BitWrapperJson, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type BodyBitJson, type BodyBitsJson, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, BoundingBoxIndex, type BreakscapeOptions, type BuildBitOptions, Builder, 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 ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtractPlainTextOptions, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type FootnoteAttibutes, type FootnoteMark, type GapJson, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, HtmlTableGenerator, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageResponsiveResourceJson, type ImageResponsiveResourceWrapperJson, 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 JsonText, type LatexTextNode, type LatexTextNodeAttributes, type LegacyPseudoAst, LegacyUnsupportedError, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, NodeType, Output, type OutputType, type PairJson, type ParserError, type ParserInfo, type ParserJson, type ParserLocation, type PersonJson, type PronunciationTableCellJson, type PronunciationTableJson, 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 SymbolMarkAttibutes, type TableCellJson, type TableExtendedJson, type TableJson, type TableRowJson, type TableSectionJson, type TaskItemTextNode, type TaskItemTextNodeAttributes, type TechnicalTermJson, type TextAndIconJson, type TextAst, type TextFormatType, type TextJsonOptions, TextLocation, type TextLocationType, 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 XRefMark, type XRefMarkAttibutes, bitmarkTextParse, isPseudoAst };
|
|
1587
|
+
export { type AppLinkResourceJson, type AppLinkResourceWrapperJson, type ArticleResourceJson, type ArticleResourceWrapperJson, Ast, type AudioEmbedResourceJson, type AudioEmbedResourceWrapperJson, type AudioLinkResourceJson, type AudioLinkResourceWrapperJson, type AudioResourceJson, type AudioResourceWrapperJson, type BaseBodyBitJson, type BaseResourceJson, type BitJson, BitType, type BitTypeType, type BitWrapperJson, BitmarkFileGenerator, BitmarkGenerator, type BitmarkOptions, BitmarkParser, BitmarkParserGenerator, BitmarkParserType, type BitmarkParserTypeType, BitmarkStringGenerator, BitmarkVersion, type BitmarkVersionType, type BodyBitJson, type BodyBitsJson, BodyTextFormat, type BodyTextFormatType, type BookJson, type BookReferenceJson, type BotResponseJson, BoundingBoxIndex, type BreakscapeOptions, type BuildBitOptions, Builder, 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 ExampleJson, type ExtRefMark, type ExtRefMarkAttibutes, type ExtractPlainTextOptions, type FeedbackChoiceJson, type FeedbackJson, type FeedbackReasonJson, type FileOptions, FileWriter, type FlashcardJson, type FootnoteAttibutes, type FootnoteMark, type GapJson, type GroupTagJson, type HeadingJson, type HeadingTextNode, type HeadingTextNodeAttributes, type HighlightJson, type HighlightTextJson, HtmlTableGenerator, HtmlTableParser, type ImageInlineTextNode, type ImageLinkResourceJson, type ImageLinkResourceWrapperJson, type ImageResourceJson, type ImageResourceWrapperJson, type ImageResponsiveResourceJson, type ImageResponsiveResourceWrapperJson, 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 JsonText, type LatexTextNode, type LatexTextNodeAttributes, type LegacyPseudoAst, LegacyUnsupportedError, type LinkMark, type LinkMarkAttibutes, type ListItemJson, type ListTextNode, type ListTextNodeAttributes, type MarkConfigJson, type MarkJson, type MatrixCellJson, type MatrixJson, type MediaAttributes, NodeType, Output, type OutputType, type PairJson, type ParserError, type ParserInfo, type ParserJson, type ParserLocation, type PersonJson, type PronunciationTableCellJson, type PronunciationTableJson, type QuestionJson, type QuizJson, type RatingLevelStartEndJson, type RefMark, type RefMarkAttibutes, ResourceBuilder, type ResourceDataJson, type ResourceJson, type ResourceMethod, 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 SymbolMarkAttibutes, 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 TextFormatType, type TextJsonOptions, TextLocation, type TextLocationType, 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 XRefMark, type XRefMarkAttibutes, bitmarkTextParse, isPseudoAst };
|
package/dist/legacy.js
CHANGED
|
@@ -45,7 +45,7 @@ function initLegacyNode(wasm2) {
|
|
|
45
45
|
// src/generated/package_info.ts
|
|
46
46
|
var PACKAGE_INFO = {
|
|
47
47
|
"name": "@gmb/bitmark-parser",
|
|
48
|
-
"version": "6.
|
|
48
|
+
"version": "6.3.0",
|
|
49
49
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
50
50
|
"license": "ISC",
|
|
51
51
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -76,16 +76,14 @@ function validateVersionOptions(opts) {
|
|
|
76
76
|
}
|
|
77
77
|
function validateBitmarkOptions(o) {
|
|
78
78
|
if (o.explicitTextFormat) unsupportedOption("bitmarkOptions.explicitTextFormat");
|
|
79
|
-
if (o.
|
|
80
|
-
unsupportedOption("bitmarkOptions.
|
|
79
|
+
if (o.cardSetVersion === 1) {
|
|
80
|
+
unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
|
|
81
81
|
}
|
|
82
|
-
if (o.cardSetVersion === 1) unsupportedOption("bitmarkOptions.cardSetVersion: 1", V3_ONLY);
|
|
83
82
|
if (o.debugGenerationInline) unsupportedOption("bitmarkOptions.debugGenerationInline");
|
|
84
83
|
if (o.noBreakscaping) unsupportedOption("bitmarkOptions.noBreakscaping");
|
|
85
84
|
}
|
|
86
85
|
function validateJsonOptions(o) {
|
|
87
86
|
if (o.textAsPlainText) unsupportedOption("jsonOptions.textAsPlainText", V3_ONLY);
|
|
88
|
-
if (o.excludeUnknownProperties) unsupportedOption("jsonOptions.excludeUnknownProperties");
|
|
89
87
|
if (o.debugGenerationInline) unsupportedOption("jsonOptions.debugGenerationInline");
|
|
90
88
|
}
|
|
91
89
|
function prettyIndent(prettify) {
|
|
@@ -121,6 +119,14 @@ function isPseudoAst(v) {
|
|
|
121
119
|
return v !== null && typeof v === "object" && (PSEUDO_AST_MARKER in v || Array.isArray(v.bits));
|
|
122
120
|
}
|
|
123
121
|
|
|
122
|
+
// src/legacy/generated/resource-collection-keys.ts
|
|
123
|
+
var RESOURCE_COLLECTION_KEYS = {
|
|
124
|
+
"extractor-image": { key: "images", resourceType: "image" },
|
|
125
|
+
"extractor-image-collapsible": { key: "images", resourceType: "image" },
|
|
126
|
+
"images-logo-grave": { key: "logos", resourceType: "image" },
|
|
127
|
+
"prototype-images": { key: "images", resourceType: "image" }
|
|
128
|
+
};
|
|
129
|
+
|
|
124
130
|
// src/legacy/builder.ts
|
|
125
131
|
var BUILT_BIT_PARSER = /* @__PURE__ */ Symbol.for("@gmb/bitmark-parser/legacy-built-bit-parser");
|
|
126
132
|
var DATA_KEY_TO_JSON_KEY = {
|
|
@@ -165,10 +171,14 @@ var Builder = class {
|
|
|
165
171
|
* NOTE (documented divergences from bpg):
|
|
166
172
|
* - the return value is bit JSON, not bpg's internal AST node model;
|
|
167
173
|
* - `resourceType` (an inference hint in bpg) is not carried into the
|
|
168
|
-
* JSON — the attached `resource` object is authoritative
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
174
|
+
* JSON — the attached `resource` object is authoritative.
|
|
175
|
+
*
|
|
176
|
+
* `resources` follows bpg's JsonGenerator routing: on a bit whose config
|
|
177
|
+
* maps a repeatable resource tag group onto a collection key (e.g.
|
|
178
|
+
* `images` / `logos` — see the generated RESOURCE_COLLECTION_KEYS), the
|
|
179
|
+
* matching-type entries land under that key; on every other bit the first
|
|
180
|
+
* entry becomes the canonical single `resource` (as bpg: "if there is
|
|
181
|
+
* more than one resource, use the first one").
|
|
172
182
|
*/
|
|
173
183
|
buildBit(data, _options) {
|
|
174
184
|
const wasm2 = getLegacyWasm();
|
|
@@ -204,12 +214,15 @@ var Builder = class {
|
|
|
204
214
|
delete src.__isDefaultExample;
|
|
205
215
|
}
|
|
206
216
|
const resources = src.resources;
|
|
207
|
-
if (resources !== void 0) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
if (resources !== void 0 && bitType !== void 0) {
|
|
218
|
+
const list = Array.isArray(resources) ? resources : [resources];
|
|
219
|
+
const collection = RESOURCE_COLLECTION_KEYS[bitType];
|
|
220
|
+
if (collection) {
|
|
221
|
+
bit[collection.key] = list.filter(
|
|
222
|
+
(r) => r !== null && typeof r === "object" && r.type === collection.resourceType
|
|
223
|
+
);
|
|
224
|
+
} else if (list.length >= 1) {
|
|
225
|
+
bit.resource = list[0];
|
|
213
226
|
}
|
|
214
227
|
delete src.resources;
|
|
215
228
|
}
|
|
@@ -227,7 +240,7 @@ var Builder = class {
|
|
|
227
240
|
}
|
|
228
241
|
}
|
|
229
242
|
this.parseStringTexts(bit);
|
|
230
|
-
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1);
|
|
243
|
+
const out = wasm2.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false);
|
|
231
244
|
if (out.startsWith("error:")) {
|
|
232
245
|
throw new Error(out.slice("error:".length).trim());
|
|
233
246
|
}
|
|
@@ -351,8 +364,10 @@ var BitmarkParserGenerator = class {
|
|
|
351
364
|
const outputFormat = opts.outputFormat ?? (isBitmark ? "json" : "bitmark");
|
|
352
365
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
353
366
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
367
|
+
const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
|
|
354
368
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
355
|
-
const
|
|
369
|
+
const includeUnknown = !jsonOptions.excludeUnknownProperties;
|
|
370
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown);
|
|
356
371
|
this.throwOnError(out);
|
|
357
372
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
358
373
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
@@ -382,7 +397,9 @@ var BitmarkParserGenerator = class {
|
|
|
382
397
|
this.checkBrowserFileWrite(opts.outputFile);
|
|
383
398
|
const wasm2 = getLegacyWasm();
|
|
384
399
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
385
|
-
const { pretty, indent } = prettyIndent(
|
|
400
|
+
const { pretty, indent } = prettyIndent(
|
|
401
|
+
isBitmark ? bitmarkOptions.prettifyJson : jsonOptions.prettify
|
|
402
|
+
);
|
|
386
403
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
387
404
|
const out = wasm2.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
|
|
388
405
|
this.throwOnError(out);
|
|
@@ -434,7 +451,7 @@ var BitmarkParserGenerator = class {
|
|
|
434
451
|
const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
|
|
435
452
|
if (!isHtmlInput) {
|
|
436
453
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
437
|
-
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1);
|
|
454
|
+
const out2 = wasm2.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false);
|
|
438
455
|
this.throwOnError(out2);
|
|
439
456
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
440
457
|
}
|
|
@@ -444,12 +461,12 @@ var BitmarkParserGenerator = class {
|
|
|
444
461
|
const { pretty, indent } = prettyIndent(jsonOptions.prettify);
|
|
445
462
|
const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
|
|
446
463
|
if (outputFormat === "html") {
|
|
447
|
-
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1);
|
|
464
|
+
const out2 = wasm2.convert(wrapped, "html", "html", "optimized", false, 2, 1, false);
|
|
448
465
|
this.throwOnError(out2);
|
|
449
466
|
return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
|
|
450
467
|
}
|
|
451
468
|
const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
|
|
452
|
-
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces);
|
|
469
|
+
const out = wasm2.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false);
|
|
453
470
|
this.throwOnError(out);
|
|
454
471
|
if (outputFormat === "bitmark" || outputFormat === "text") {
|
|
455
472
|
return this.deliver(out, opts.outputFile, opts.fileOptions);
|
|
@@ -474,7 +491,7 @@ var BitmarkParserGenerator = class {
|
|
|
474
491
|
const opts = Object.assign({}, options);
|
|
475
492
|
const wasm2 = getLegacyWasm();
|
|
476
493
|
const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
|
|
477
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1);
|
|
494
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true);
|
|
478
495
|
this.throwOnError(out);
|
|
479
496
|
return makePseudoAst(JSON.parse(out));
|
|
480
497
|
}
|
|
@@ -581,7 +598,7 @@ var BitmarkParserGenerator = class {
|
|
|
581
598
|
}
|
|
582
599
|
}
|
|
583
600
|
const { source, isBitmark } = this.resolveInput(input, void 0);
|
|
584
|
-
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1);
|
|
601
|
+
const out = wasm2.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false);
|
|
585
602
|
this.throwOnError(out);
|
|
586
603
|
return out;
|
|
587
604
|
}
|