Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alexandria:0.1.2 #1963

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/preview/alexandria/0.1.2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
62 changes: 62 additions & 0 deletions packages/preview/alexandria/0.1.2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

<details>
<summary>Migration guide from v0.1.x</summary>

<!-- Write migration guide here -->

</details>

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

## [0.1.2] - 2025-03-08

### Added
- support for `bytes` as a bib or csl file parameter, to be up-to-date with Typst 0.13's `bibliography()` API

## [0.1.1] - 2025-02-12

### Added
- `load-bibliography` that stores bib data for later retrieval
- `get-bibliography` that retrieves the data
- `render-bibliography` that renders the bib data
- add details (type, title, author, ...) to data available for bibliography users
- add support for custom CSL styles loaded from files

### Fixed
- fixed a deprecation warning when running Typst 0.13
- split bibliographyx into load, get and render parts

## [0.1.0] - 2025-02-06

### Added

- plugin for rendering references and citations
- Typst wrapper for
- collecting citations
- calling the plugin
- processing its results (rendering structured data into styled content)
- Tests for IEEE and APA references in English and German (APA tests are deactivated to to something that's probably a Typst bug)


[Unreleased]: https://github.com/SillyFreak/typst-alexandria/compare/v0.1.2...HEAD
[0.1.2]: https://github.com/SillyFreak/typst-alexandria/releases/tag/v0.1.2
[0.1.1]: https://github.com/SillyFreak/typst-alexandria/releases/tag/v0.1.1
[0.1.0]: https://github.com/SillyFreak/typst-alexandria/releases/tag/v0.1.0
22 changes: 22 additions & 0 deletions packages/preview/alexandria/0.1.2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2024 Clemens Koza

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 changes: 38 additions & 0 deletions packages/preview/alexandria/0.1.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Alexandria

This package provides an alternative to the built-in bibliography to allow a single document to have multiple bibliographies.

This package currently has a few limitations, such as not being able to collapse citations yet, but more general support is planned soon.

## Getting Started

To add this package to your project, use this:

```typ
#import "@preview/alexandria:0.1.2": *

#show: alexandria(prefix: "x-", read: path => read(path))

...

#bibliographyx(
"bibliography.bib",
// title: auto is not yet supported so it needs to be specified
title: "Bibliography",
)
```

<picture>
<source media="(prefers-color-scheme: dark)" srcset="./thumbnail-dark.svg">
<img src="./thumbnail-light.svg">
</picture>

## Usage

See the [manual](docs/manual.pdf) for details.

## License

Parts of the Rust plugin that interfaces with the [Hayagriva](https://github.com/typst/hayagriva) citation library are based on [typst-library's `bibliography.rs`](https://github.com/typst/typst/blob/26e65bfef5b1da7f6c72e1409237cf03fb5d6069/crates/typst-library/src/model/bibliography.rs). Likewise, the example bibliographies are taken or adapted from [typst-dev-assets' `works.bib`](https://github.com/typst/typst-dev-assets/blob/1dba4bea22e5e19597fbf5f321b047ff7626e2d0/files/bib/works.bib). Both are licensed from Typst's authors under the Apache License 2.0.

The example CSL style [`ieee.csl`](https://github.com/citation-style-language/styles/blob/fd6cb3e81762055d107839c3c288c359985f81c8/ieee.csl) is taken from the [CSL project](https://citationstyles.org/) who provide it under the [Creative Commons Attribution-ShareAlike 3.0 Unported license](https://creativecommons.org/licenses/by-sa/3.0/).
Binary file not shown.
Binary file not shown.
Binary file not shown.
59 changes: 59 additions & 0 deletions packages/preview/alexandria/0.1.2/src/hayagriva.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#let _p = plugin("alexandria.wasm")

#let names = {
// Typst 0.13: `cbor.decode` is deprecated, directly pass bytes to `cbor` instead
let decode = if sys.version < version(0, 13, 0) { cbor.decode } else { cbor }

decode(_p.names())
}

#let read(
sources,
full,
style,
locale,
citations,
) = {
// Typst 0.13: `cbor.decode` is deprecated, directly pass bytes to `cbor` instead
let decode = if sys.version < version(0, 13, 0) { cbor.decode } else { cbor }

let config = cbor.encode((sources: sources, full: full, style: style, locale: locale, citations: citations))
decode(_p.read(config))
}

#let render(body) = {
if type(body) == array {
body.map(render).join()
} else if "text" in body {
let body = body.text
set text(style: "italic") if body.font-style == "italic"
// TODO this is an absolute weight and not an offset
set text(weight: "bold") if body.font-weight == "bold"
set text(weight: "light") if body.font-weight == "light"
show: it => {
if body.font-variant == "small-caps" {
it = smallcaps(it)
}
if body.text-decoration == "underline" {
it = underline(it)
}
if body.vertical-align == "sup" {
it = h(0pt, weak: true) + super(it)
} else if body.vertical-align == "sub" {
it = h(0pt, weak: true) + sub(it)
}
it
}
body.text
} else if "elem" in body {
let body = body.elem
// TODO handle body.display when present
render(body.children)
} else if "link" in body {
let body = body.link
link(body.url, render(body.text))
} else {
set text(red)
repr(body)
}
}
13 changes: 13 additions & 0 deletions packages/preview/alexandria/0.1.2/src/internal.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#let locale() = {
let locale = text.lang
if text.region != none { locale += "-" + text.region }
locale
}

#let csl-to-string(csl) = {
if type(csl) in (str, bytes) { return csl }

let csl = repr(csl).slice(1, -1)
assert.ne(csl, "..", message: "only named CSL styles can be converted to strings")
csl
}
Loading
Loading