Documentation
¶
Index ¶
- func ConvertHTMLFileToEPUB(htmlPath string, options EPUBOptions) (string, error)
- func ConvertHTMLFileToPDF(htmlPath string, options PDFOptions) (string, error)
- func ConvertHTMLToEPUB(htmlContent string, outputPath string, options EPUBOptions) error
- func ConvertHTMLToPDF(htmlContent string, outputPath string, options PDFOptions) error
- func ConvertImageToPDF(imgPath string) (string, error)
- func ConvertImageToPDFWithSettings(imgPath, resolution string, dpi float64) (string, error)
- func DownloadImage(imageURL, outputPath string) error
- func SaveMarkdownAsHTML(mdPath string) (string, error)
- type ArticleContent
- type EPUBOptions
- type MarkdownContent
- type MarkdownMetadata
- type PDFOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertHTMLFileToEPUB ¶ added in v1.7.0
func ConvertHTMLFileToEPUB(htmlPath string, options EPUBOptions) (string, error)
ConvertHTMLFileToEPUB reads an HTML file and converts it to EPUB.
func ConvertHTMLFileToPDF ¶ added in v1.7.0
func ConvertHTMLFileToPDF(htmlPath string, options PDFOptions) (string, error)
ConvertHTMLFileToPDF reads an HTML file and converts it to PDF.
func ConvertHTMLToEPUB ¶ added in v1.7.0
func ConvertHTMLToEPUB(htmlContent string, outputPath string, options EPUBOptions) error
ConvertHTMLToEPUB creates an EPUB file from HTML content. It downloads and embeds images, rewrites image paths, and applies metadata.
func ConvertHTMLToPDF ¶ added in v1.7.0
func ConvertHTMLToPDF(htmlContent string, outputPath string, options PDFOptions) error
ConvertHTMLToPDF creates a PDF file from HTML content using EPUB → PDF pipeline. It first generates an EPUB (which handles images and styling well), then converts to PDF using mutool.
func ConvertImageToPDF ¶
ConvertImageToPDF takes an input image path (must end in .jpg, .jpeg, or .png), reads PAGE_RESOLUTION (pixels) and PAGE_DPI from the environment (defaulting to Remarkable 2’s specs), and invokes ImageMagick’s convert to produce a PDF whose page size is exactly the target pixel resolution, with the image scaled down if larger, or left at its original size if smaller. It writes the output PDF alongside the input (basename + ".pdf") and returns its full path.
func ConvertImageToPDFWithSettings ¶ added in v1.4.0
ConvertImageToPDFWithSettings takes an input image path and custom resolution/DPI settings, converts it to PDF using the specified settings, falling back to environment defaults if empty.
func DownloadImage ¶ added in v1.7.0
DownloadImage fetches an image from a URL and saves it to the specified path. Returns an error if the download fails.
func SaveMarkdownAsHTML ¶ added in v1.7.0
SaveMarkdownAsHTML converts a Markdown file to HTML and saves it to disk. Returns the path to the generated HTML file.
Types ¶
type ArticleContent ¶ added in v1.7.0
type ArticleContent struct {
HTML string // Clean HTML content
Title string // Article title
Byline string // Author/byline
Excerpt string // Short excerpt
Images []string // Image URLs found in the article
}
ArticleContent represents the extracted clean article content
func ExtractFromHTML ¶ added in v1.7.0
func ExtractFromHTML(htmlPath string) (*ArticleContent, error)
ExtractFromHTML reads an HTML file from disk and extracts readable article content. It applies the same readability processing to remove clutter.
func ExtractFromHTMLString ¶ added in v1.7.0
func ExtractFromHTMLString(html string, baseURL *url.URL) (*ArticleContent, error)
ExtractFromHTMLString processes an HTML string and extracts readable content. This is useful when you already have HTML in memory.
func ExtractFromURL ¶ added in v1.7.0
func ExtractFromURL(urlStr string) (*ArticleContent, error)
ExtractFromURL fetches a URL and extracts readable article content using go-readability. It removes ads, navigation, scripts, and other non-content elements.
type EPUBOptions ¶ added in v1.7.0
type EPUBOptions struct {
Title string
Author string
Description string
Language string
CSSContent string
SourceURL string
}
EPUBOptions contains options for EPUB generation
type MarkdownContent ¶ added in v1.7.0
type MarkdownContent struct {
HTML string
Metadata MarkdownMetadata
}
MarkdownContent represents the converted Markdown content
func ConvertMarkdownStringToHTML ¶ added in v1.7.0
func ConvertMarkdownStringToHTML(mdContent string) (*MarkdownContent, error)
ConvertMarkdownStringToHTML converts a Markdown string to HTML. It parses YAML frontmatter for metadata and returns clean HTML.
func ConvertMarkdownToHTML ¶ added in v1.7.0
func ConvertMarkdownToHTML(mdPath string) (*MarkdownContent, error)
ConvertMarkdownToHTML converts a Markdown file to HTML using goldmark. It parses YAML frontmatter for metadata and returns clean HTML.
type MarkdownMetadata ¶ added in v1.7.0
MarkdownMetadata contains metadata extracted from Markdown frontmatter
type PDFOptions ¶ added in v1.7.0
type PDFOptions struct {
Title string
PageSize string // e.g., "A4", "Letter", or custom like "1404x1872"
MarginTop string // e.g., "10mm"
MarginBottom string
MarginLeft string
MarginRight string
DPI uint // Dots per inch for rendering
SourceURL string
}
PDFOptions contains options for PDF generation
func GetPDFOptionsForUser ¶ added in v1.7.0
func GetPDFOptionsForUser(pageResolution string, pageDPI float64) PDFOptions
GetPDFOptionsForUser creates PDFOptions using user settings with environment fallback.
func GetPDFOptionsFromConfig ¶ added in v1.7.0
func GetPDFOptionsFromConfig() PDFOptions
GetPDFOptionsFromConfig creates PDFOptions from environment configuration.