CSL-style citation and bibliography rendering for MoonBit
git clone https://github.com/yujieMamba/mooncite.git
cd mooncite
moon version --all
moonc -v
moon check --target wasm-gc --deny-warn
moon test --target wasm-gclet style = """
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0">
<info><title>Demo</title><id>http://example.org/demo</id></info>
<citation><layout prefix="(" suffix=")"><text variable="title"/></layout></citation>
<bibliography><layout><names variable="author" suffix=". "><name/></names><date variable="issued" prefix="(" suffix="). "><date-part name="year"/></date><text variable="title"/></layout></bibliography>
</style>
"""
let processor = @mooncite.Processor::from_style(style).unwrap()
let item = @mooncite.Item::new("paper")
item.set_string("title", "A short paper")
item.set_name("author", [@mooncite.CslName::new(family="Doe", given="Jane")])
item.set_date("issued", @mooncite.CslDate::new(2024))
let result = processor.render_bibliography([item])
println(result.unwrap())moon run cmd/main
moon run examples/beginners
moon run examples/numeric
moon run examples/text-extractpub struct Affix {
prefix : String
suffix : String
delimiter : String
text_case : String
font_style : String
font_weight : String
vertical_align : String
}pub enum Condition {
Variable(String)
Type(String)
Numeric(String)
IsUncertain(String)
IsPlural(String)
Position(String)
}pub struct DatePart {
name : String
form : String
prefix : String
suffix : String
range_delimiter : String
text_case : String
}pub(all) struct Item {
id : String
title : String
container_title : String
publisher : String
publisher_place : String
volume : String
issue : String
page : String
edition : String
url : String
doi : String
item_type : String
abstract_text : String
names : Map[String, Array[CslName]]
dates : Map[String, CslDate]
strings : Map[String, String]
numbers : Map[String, Int]
booleans : Map[String, Bool]
} derive(Debug)pub struct NameNode {
variable : String
form : String
and_word : String
delimiter : String
initialize_with : String
initialize : Bool
name_as_sort_order : String
delimiter_precedes_last : String
et_al_min : Int
et_al_use_first : Int
label_variable : String
}pub struct NumberNode {
variable : String
form : String
prefix : String
suffix : String
delimiter : String
text_case : String
}pub struct SortKey {
variable : String
macro_name : String
names_min : Int
names_use_first : Int
sort_order : String
}pub struct Style {
title : String
version : String
default_locale : String
macros : Map[String, Array[Node]]
citation : Layout?
bibliography : Layout?
citation_sort : Array[SortKey]
bibliography_sort : Array[SortKey]
citation_disambiguate : Bool
citation_collapse : String
citation_delimiter : String
}pub struct TextNode {
variable : String
value : String
macro_name : String
term : String
form : String
}fn normalize_page_range(value : String) -> StringInstall
Download zipCSL-style citation and bibliography rendering for MoonBit