Skip to content

Commit

Permalink
print headings as bold
Browse files Browse the repository at this point in the history
  • Loading branch information
tatchi committed Mar 18, 2024
1 parent af3e1f6 commit bddd8fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/mrkdwn.ml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,21 @@ module Cmarkit_slack = struct
| Inline.Link (l, _) -> link c l
| _ -> false (* let the default renderer handle that *)
in
let block c block =
let open Cmarkit in
let module C = Cmarkit_renderer.Context in
match block with
| Block.Heading (heading, _) ->
let inline = Block.Heading.inline heading in
C.byte c '*';
C.inline c inline;
C.byte c '*';
C.byte c '\n';
true
| _ -> false
in
let default_renderer = Cmarkit_commonmark.renderer () in
let renderer = Cmarkit_renderer.make ~inline () in
let renderer = Cmarkit_renderer.make ~inline ~block () in
Cmarkit_renderer.compose default_renderer renderer
end

Expand Down
16 changes: 16 additions & 0 deletions lib_test/mrkdwn/mrkdwn_of_md.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,19 @@ link
> [hello](https://google.be)
> MD
<https://google.be|hello>

headings
$ mrkdwn_of_md << "MD"
> # one
> ## two
> ### three
> #### four
> ##### five
> ###### six
> MD
*one*
*two*
*three*
*four*
*five*
*six*

0 comments on commit bddd8fd

Please sign in to comment.