module Jrsl

Defined in:

jrsl.cr

Constant Summary

IMAGE_MAX_WIDTH = 119

Maximum width in terminal columns for rendered images

VERSION = "0.4.0"

Class Method Summary

Class Method Detail

def self.calculate_image_max_height(md_rows : Int32, content_area_height : Int32, image_position : String, image_h_position : String) : Int32 #

Calculate available height for image based on markdown size and position


[View source]
def self.center_x(screen_width : Int32, content_cols : Int32) : Int32 #

Column where a block of content_cols cells starts to be centered on a screen of screen_width columns


[View source]
def self.effective_image_width(screen_width : Int32) : Int32 #

Effective maximum image width in cells: never wider than the screen


[View source]
def self.fence_close_marker(line : String) : String | Nil #

Return "```" or "~~~" when the line consists solely of fence marker characters, i.e. it can close a fenced code block


[View source]
def self.fence_open_marker(line : String) : String | Nil #

Return "```" or "~~~" when the line opens a fenced code block: at least 3 marker characters, optionally indented, optionally followed by an info string (CommonMark allows no info string on closing fences)


[View source]
def self.image_x_position(h_position : String, screen_width : Int32, img_cols : Int32) : Int32 #

Column where the image starts given its horizontal placement setting


[View source]
def self.load_image(path : String) : CrImage::Image | Nil #

[View source]
def self.normalize_for_figlet(text : String) : String #

Normalize accented characters to ASCII for figlet


[View source]
def self.parse_global_metadata(lines : Array(String)) : Tuple(PresentationMetadata, Int32) #

Parse the optional global YAML metadata block at the top of the file. Returns the metadata and the line index where slide parsing starts.


[View source]
def self.parse_slide_blocks(lines : Array(String), start_index : Int32) : Array(Slide) #

Parse alternating blocks starting at start_index: slide metadata (YAML) followed by content (markdown), separated by "---" lines


[View source]
def self.parse_slides(content : String) : Tuple(Array(Slide), PresentationMetadata) #

[View source]
def self.query_cell_size : Tuple(Int16, Int16) | Nil #

Returns {cell_height_px, cell_width_px}, or nil when the terminal does not report pixel dimensions (very common outside graphical terminals).


[View source]
def self.read_slide_content(lines : Array(String), i : Int32) : Tuple(Array(String), Int32) #

Read the slide content (markdown) lines starting at index i, until the next "---" delimiter or end of file. "---" lines inside fenced code blocks do not count as delimiters. Returns the content lines and the index of the delimiter (or lines.size).


[View source]
def self.read_slide_metadata(lines : Array(String), i : Int32) : Tuple(SlideMetadata, Int32) #

Read the slide metadata (YAML) lines starting at index i. Returns the parsed metadata and the index after any "---" delimiter.


[View source]
def self.render_image_kitty(path : String, max_width : Int32, max_height : Int32) : Tuple(String, Int32, Int32) | Nil #

Render image using Kitty graphics protocol Returns the escape sequence string to display the image


[View source]
def self.render_image_to_string(path : String, max_width : Int32, max_height : Int32) : Tuple(String, Int32, Int32) | Nil #

Pre-render an image to a string before TUI initialization Uses half-block characters (▀) for 2x1 vertical resolution per cell Returns {rendered_string, line_count, width_in_chars} or nil if loading fails


[View source]
def self.render_markdown_to_element(markdown : String, max_width : Int32) : MarkdownElement #

Render markdown to a MarkdownElement with measured dimensions


[View source]
def self.side_by_side_layout(h_position : String, screen_width : Int32, img_cols : Int32) : Tuple(Int32, Int32) #

Side-by-side layout columns: Returns {image_x, md_x}


[View source]
def self.stacked_layout(position : String, content_area_start : Int32, content_area_height : Int32, img_rows : Int32, md_rows : Int32) : Tuple(Int32, Int32, Int32) #

Vertical positions for stacked layouts. Returns {img_y, md_y, available_md_height}


[View source]