Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Asciicast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function Base.show(io::IO, ::MIME"juliavscode/html", cast::Cast)
end

function show_html(io::IO, cast::Cast)
base64_str = base64encode(collect_bytes(cast))
base64_str = base64encode(collect_bytes(cast))
name = uuid4()
# Note: the extra div with `margin` is me trying to make the asciinema player
# have a little space around it, so it looks better in documenter pages etc.
Expand All @@ -164,7 +164,7 @@ function show_html(io::IO, cast::Cast)
<script>
AsciinemaPlayer.create(
'data:text/plain;base64,$(base64_str)',
document.getElementById('$(name)'), {autoPlay: true, fit: false, loop: $(cast.loop)}
document.getElementById('$(name)'), {autoPlay: true, fit: "width", loop: $(cast.loop)}
);
</script>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ function Selectors.runner(::Type{CastBlocks}, node, page, doc)
height = parse(Int, matched[1])
end

# width
matched = match(r"\bwidth\s*=\s*([0-9]+)", kwargs)
if matched !== nothing
width = parse(Int, matched[1])
end

# loop
# bool:
matched = match(r"\bloop\s*=\s*(true|false)\b", kwargs)
Expand Down Expand Up @@ -91,7 +97,8 @@ function Selectors.runner(::Type{CastBlocks}, node, page, doc)

# If `height` isn't provided, we guess the number of lines:
height = something(height, min(n_lines * 2, 24))
cast = Cast(IOBuffer(), Header(; height, idle_time_limit=1); delay, loop)
width = something(width, 80)
cast = Cast(IOBuffer(), Header(; height, width, idle_time_limit=1); delay, loop)

cast_from_string!(x.code, cast; doc, page, ansicolor, mod, multicodeblock, allow_errors, x)

Expand Down
Loading