Bushel.MdMarkdown processing with Bushel link extensions.
Bushel Markdown extensions and utilities
This module provides mappers to convert Bushel markdown extensions to different output formats. Bushel extends standard markdown with:
:slug - Links to bushel entries by slug@@handle - Links to contacts by handle##tag - Tag referencesTwo main mapper modes:
Sidenote data types for interactive previews on hover. These are defined here as Cmarkit inline extensions that can be generated by the sidenote mapper and rendered by the webserver.
type sidenote_data = | Contact_note of Sortal_schema.Contact.t * string| Paper_note of Bushel__.Bushel_paper.t * string| Idea_note of Bushel__.Bushel_idea.t * string| Note_note of Bushel__.Bushel_note.t * string| Project_note of Bushel__.Bushel_project.t * string| Video_note of Bushel__.Bushel_video.t * string| Footnote_note of string * Cmarkit.Block.t * stringExtensible inline for sidenotes
val authorlink : unit Cmarkit.Meta.keyval sluglink : unit Cmarkit.Meta.keyval make_authorlink : Cmarkit.Label.t -> Cmarkit.Label.tval make_sluglink : Cmarkit.Label.t -> Cmarkit.Label.tval with_bushel_links :
[< `Def of Cmarkit.Label.t option * Cmarkit.Label.t
| `Ref of 'a * Cmarkit.Label.t * Cmarkit.Label.t option ] ->
Cmarkit.Label.t optionCustom label resolver for Bushel links
val text_of_inline : Cmarkit.Inline.t -> stringval link_target_is_bushel :
?slugs:(string, unit) Hashtbl.t ->
Cmarkit.Inline.Link.t ->
(string * string) optionval image_target_is_bushel :
Cmarkit.Inline.Link.t ->
(string * Cmarkit.Block_line.tight list option * string) optionStrips bushel links from the AST and extracts plain text. Follows the same detection pattern as the sidenote and HTML mappers:
text(:slug) detected via link_target_is_busheltext:slug detected via authorlink/sluglink metadata tags set by the resolver:slug and ##tag links are deleted@@handle links are replaced with the contact's full nameval inline_to_plain_text : Cmarkit.Inline.t -> stringval make_plain_text_mapper :
?contact_name:(String.t -> String.t option) ->
unit ->
Cmarkit.Mapper.tCreates sidenotes for Bushel links. Used for interactive previews on the main website.
Resolve link text: if it looks like a bushel slug, look up the entry title.
val make_sidenote_mapper :
Bushel__.Bushel_entry.t ->
'a ->
Cmarkit.Inline.t ->
Cmarkit.Inline.t Cmarkit.Mapper.resultval make_bushel_inline_mapper :
Bushel__.Bushel_entry.t ->
'a ->
Cmarkit.Inline.t ->
Cmarkit.Inline.t Cmarkit.Mapper.resultAlias for compatibility
Converts Bushel links to regular HTML links without sidenotes. Used for Atom feeds, RSS, search indexing.
val make_link_only_mapper :
Bushel__.Bushel_entry.t ->
'a ->
Cmarkit.Inline.t ->
Cmarkit.Inline.t Cmarkit.Mapper.resultval make_bushel_link_only_mapper :
'a ->
Bushel__.Bushel_entry.t ->
'b ->
Cmarkit.Inline.t ->
Cmarkit.Inline.t Cmarkit.Mapper.resultAlias for compatibility
val scan_for_slugs : 'a -> string -> Cmarkit.Label.key listval extract_all_links : string -> String.t listExtract all links from markdown text, including from images
val extract_external_links : string -> String.t listExtract external URLs from markdown content
Convert markdown text to plain text, resolving bushel links to just their text
val make_validation_mapper :
Bushel__.Bushel_entry.t ->
(Cmarkit.Label.key, unit) Hashtbl.t ->
(Cmarkit.Label.key, unit) Hashtbl.t ->
'a ->
Cmarkit.Inline.t ->
'b Cmarkit.Mapper.resultValidation mapper that collects broken references
val validate_references :
Bushel__.Bushel_entry.t ->
string ->
Cmarkit.Label.key list * Cmarkit.Label.key listValidate all bushel references in markdown and return broken ones
val make_to_markdown_mapper :
?base_url:string ->
?image_base:string ->
Bushel__.Bushel_entry.t ->
'a ->
Cmarkit.Inline.t ->
Cmarkit.Inline.t Cmarkit.Mapper.resultCreate a mapper that converts Bushel markdown to standard markdown.
This resolves:
:slug links to Title(URL)@@handle to Name(best_url)##tag to tag(/tags/tag):image-slug(caption) to !caption(/images/slug.webp)val to_markdown :
?base_url:string ->
?image_base:string ->
entries:Bushel__.Bushel_entry.t ->
string ->
stringConvert Bushel markdown to standard markdown.
Reference extraction for CiTO annotations.
Reference source type for CiTO annotations
val note_references :
Bushel__.Bushel_entry.t ->
Sortal_schema.Contact.t ->
Bushel__.Bushel_note.t ->
(string * string * reference_source) listExtract references (papers/notes with DOIs) from a note. Returns a list of (doi, citation_text, reference_source) tuples.