@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
149 lines • 3.85 kB
TypeScript
import { Item } from '../../../../pkg/md/parser/item';
import { MarkdownRenderer, Shortcode } from "../../../domain/markdown";
import { MediaType } from '../../../../pkg/media/type';
/**
* Content replacement item
*/
export interface ContentReplacement {
/** Replacement value */
val: Uint8Array;
/** Source item */
source: Item;
}
/**
* Content item type - can be Item, Shortcode, or ContentReplacement
*/
export type ContentItem = Item | Shortcode | ContentReplacement;
/**
* Summary divider constants
*/
export declare const INTERNAL_SUMMARY_DIVIDER_BASE = "HUGOMORE42";
export declare const INTERNAL_SUMMARY_DIVIDER_PRE: Uint8Array<ArrayBufferLike>;
/**
* Content class - manages parsed content with shortcodes and replacements
*/
export declare class Content {
private hasSummaryDivider;
private summaryTruncated;
private rawSource;
private items;
private renderer;
constructor(source: Uint8Array, renderer: MarkdownRenderer);
/**
* Check if content is empty
*/
isEmpty(): boolean;
/**
* Set summary divider flag
*/
setSummaryDivider(): void;
/**
* Check if content has summary divider
*/
getHasSummaryDivider(): boolean;
/**
* Set summary truncated flag
*/
setSummaryTruncated(): void;
/**
* Check if summary is truncated
*/
getTruncated(): boolean;
/**
* Add replacement item
*/
addReplacement(val: Uint8Array, source: Item): void;
/**
* Add shortcode
*/
addShortcode(shortcode: Shortcode): void;
/**
* Add parsed item
*/
addItem(item: Item): void;
/**
* Add multiple items
*/
addItems(...items: Item[]): void;
/**
* Get raw content as string
*/
rawContent(): string;
/**
* Get pure content (with replacements and shortcodes processed)
*/
pureContent(): string;
pureContentWithoutPlaceholder(): string;
/**
* Get content with shortcodes rendered
*/
renderedContent(shortcodeRenderer?: (shortcode: Shortcode) => string): string;
/**
* Get content with shortcodes rendered (async version)
*/
renderedContentAsync(shortcodeRenderer?: (shortcode: Shortcode) => Promise<string> | string): Promise<string>;
/**
* Get all items
*/
getItems(): ContentItem[];
/**
* Get shortcodes only
*/
getShortcodes(): Shortcode[];
/**
* Get regular items only
*/
getTextItems(): Item[];
/**
* Get content replacements only
*/
getReplacements(): ContentReplacement[];
/**
* Check if summary is empty
*/
isSummaryEmpty(): boolean;
/**
* Extract summary automatically when summary is empty
*/
extractSummary(input: Uint8Array, mediaType: MediaType): {
summary: string;
truncated: boolean;
};
/**
* Extract summary from HTML content
*/
private extractSummaryFromHTML;
/**
* Check if string contains CJK characters
*/
private containsCJK;
/**
* Check if a word is probably an HTML token
*/
private isProbablyHTMLToken;
/**
* Strip HTML tags from string
*/
private stripHTML;
/**
* Trim short HTML content (remove single p tags if they wrap the entire content)
*/
private trimShortHTML;
/**
* Get content summary (up to summary divider)
*/
getSummary(maxLength?: number): string;
getRenderedSummary(maxLength?: number): Promise<string>;
/**
* Get word count
*/
getWordCount(): number;
/**
* Get reading time estimate (words per minute)
*/
getReadingTime(wordsPerMinute?: number): number;
private isItem;
private isShortcode;
private isContentReplacement;
}
//# sourceMappingURL=content.d.ts.map