Skip to content

Commit

Permalink
Fix attributes not being rewritten well
Browse files Browse the repository at this point in the history
Signed-off-by: Paul-Elliot <[email protected]>
  • Loading branch information
panglesd committed Mar 22, 2024
1 parent 7d22bf4 commit 876d95c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 8 additions & 4 deletions compiler/src/lib/mappings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ open Cmarkit

let of_cmarkit resolve_images =
let block m = function
| Block.Block_quote ((bq, ((attrs, _) as a)), meta) ->
| Block.Block_quote ((bq, (attrs, meta2)), meta) ->
if Attributes.mem "blockquote" attrs then Mapper.default
else
let b = Block.Block_quote.block bq in
let b =
match Mapper.map_block m b with None -> Block.empty | Some b -> b
in
Mapper.ret (Ast.Div ((b, a), meta))
| Block.Code_block (((cb, _), _) as cbm) ->
let attrs = Mapper.map_attrs m attrs in
Mapper.ret (Ast.Div ((b, (attrs, meta2)), meta))
| Block.Code_block ((cb, (attrs, meta)), meta2) ->
let ret =
match Block.Code_block.info_string cb with
| None -> Mapper.default
| Some (info, _) -> (
match Block.Code_block.language_of_info_string info with
| Some ("slip-script", _) -> Mapper.ret (Ast.SlipScript cbm)
| Some ("slip-script", _) ->
Mapper.ret
(Ast.SlipScript
((cb, (Mapper.map_attrs m attrs, meta)), meta2))
| _ -> Mapper.default)
in
ret
Expand Down
1 change: 0 additions & 1 deletion compiler/src/lib/slipshow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ let embed_in_page content ~starting_state ~has_math ~math_link ~slip_css_link
let convert ?starting_state ?math_link ?slip_css_link ?theorem_css_link
?slipshow_js_link ?(resolve_images = fun x -> Remote x) s =
let md = Cmarkit.Doc.of_string ~heading_auto_ids:true ~strict:false s in
ignore resolve_images;
let md = Cmarkit.Mapper.map_doc (Mappings.of_cmarkit resolve_images) md in
let content =
Cmarkit_renderer.doc_to_string Renderers.custom_html_renderer md
Expand Down

0 comments on commit 876d95c

Please sign in to comment.