diff --git a/packages/preview/pannotyp/0.0.1/LICENSE b/packages/preview/pannotyp/0.0.1/LICENSE new file mode 100644 index 0000000000..0e259d42c9 --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/packages/preview/pannotyp/0.0.1/README.md b/packages/preview/pannotyp/0.0.1/README.md new file mode 100644 index 0000000000..af12f88870 --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/README.md @@ -0,0 +1,53 @@ +# PannoTyp + +This module adds Hungarian language support to Typst. + +> Unless You are writing something in Hungarian You do not need this +> module at all. + +## Features + +### Hungarian style definitions + +This module sets up shome `show` rules: + - Hungarian-style captions: + - `1 ábra: Ábra felirata` + - `2.1 táblázat: Táblázat felirata` + - `(3.3) egyenlet` + - Hungarian-style references: + - `1. ábra` + - `3. oldal` + +### Helper functions + +To help writing Hungarian documents the package defines the following helper +functions: + - `#aref` and `#Aref` for handling definite article cases. + - `#hq` for Hungarian-style quoting. + - `#told` for generating various Hungarian suffixes. + - `#atold` and `#Atold` for mixing `aref` and `told` functions. + +## Usage + +```typst +#import "@preview/pannotyp:0.0.1" as pt +#show: pt.init +``` + +> You can also import the modules like +> ```typst +> #import "@preview/pannotyp:0.0.1": * +> #show: init +> ``` +> this way You can omit `pt.` from every function name, but it can cause name +> collisions. + +Please refer to [Releases](https://codeberg.org/voroskoi/PannoTyp/releases) +page for the latest +[manual](https://codeberg.org/voroskoi/PannoTyp/releases/download/v0.0.1/manual.pdf). + +## Changelog + +### v0.0.1 + +Initial Release diff --git a/packages/preview/pannotyp/0.0.1/src/aref.typ b/packages/preview/pannotyp/0.0.1/src/aref.typ new file mode 100644 index 0000000000..ab03b48d8b --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/src/aref.typ @@ -0,0 +1,57 @@ +#import "util.typ" + +#let AAZ(i) = { + if i > 999 { + return AAZ(i / 1000) + } + if i == 1 or i == 5 or (i > 49 and i < 60) or (i > 499 and i < 600) { + "Az " + } else { + "A " + } +} + +#let Anoref(target, form: "normal", supplement: auto) = { + context { + let i = none + if form == "page" { + i = counter(page).at(target).first() + } else { + i = util.getLabelCounterFirst(target) + } + AAZ(i) + } +} + +#let Aref(target, form: "normal", supplement: auto) = { + Anoref(target, form: form, supplement: supplement) + ref(target, form: form, supplement: supplement) +} + +#let aaz(i) = { + if i > 999 { + return aaz(i / 1000) + } + if i == 1 or i == 5 or (i > 49 and i < 60) or (i > 499 and i < 600) { + "az " + } else { + "a " + } +} + +#let anoref(target, form: "normal", supplement: auto) = { + context { + let i = none + if form == "page" { + i = counter(page).at(target).first() + } else { + i = util.getLabelCounterFirst(target) + } + aaz(i) + } +} + +#let aref(target, form: "normal", supplement: auto) = { + anoref(target, form: form, supplement: supplement) + ref(target, form: form, supplement: supplement) +} diff --git a/packages/preview/pannotyp/0.0.1/src/panno.typ b/packages/preview/pannotyp/0.0.1/src/panno.typ new file mode 100644 index 0000000000..4a936539cb --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/src/panno.typ @@ -0,0 +1,235 @@ +#import "aref.typ" as r +#import "quote.typ" as q +#import "told.typ" as t + +#let header_supplements_hun = ( + part: "rész", + volume: "kötet", + chapter: "fejezet", + section: "szakasz", + subsection: "alszakasz", + subsubsection: "alalszakasz", +) + +#let supplements_hun = ( + equation: "egyenlet", + image: "ábra", + table: "táblázat", + page: "oldal", + raw: "kódrészlet", +) + +/// Az alapértelmezett beállítások, amelyek átadásra kerülnek az @cmd:init függvénynek. +/// -> dict +#let config_default = ( + lang: "hu", + headers: header_supplements_hun, + supplements: supplements_hun, +) + +/// A modul inicializálása. +#let init( + /// Beállítások + conf: config_default, + /// Minden a ```typ #show: pt.init``` sor után + it, +) = { + set text(lang: conf.lang) + + // Page supplement + set page(supplement: conf.supplements.page) + + // Header supplement setup + show heading.where(level: 1): set heading(supplement: conf.headers.part) + show heading.where(level: 2): set heading(supplement: conf.headers.volume) + show heading.where(level: 3): set heading(supplement: conf.headers.chapter) + show heading.where(level: 4): set heading(supplement: conf.headers.section) + show heading.where(level: 5): set heading(supplement: conf.headers.subsection) + show heading.where(level: 6): set heading( + supplement: conf.headers.subsubsection, + ) + + // Image, table and raw supplements + show figure.where(kind: image): set figure(supplement: conf.supplements.image) + show figure.where(kind: table): set figure(supplement: conf.supplements.table) + show figure.where(kind: raw): set figure(supplement: conf.supplements.raw) + + // Equation supplement + show math.equation: set math.equation(supplement: conf.supplements.equation) + + // Sets up Hungarian caption style + show figure.caption: it => { + let counter_text = context it.counter.display(it.numbering) + box(counter_text + " " + it.supplement + it.separator) + it.body + } + + // Sets up Hungarian reference style. + show ref: it => { + // + // Page reference + // + if it.form == "page" { + let num_style = none + if page.numbering == none { + num_style = "1" + } else { + num_style = page.numbering + } + let pn = numbering(num_style, ..counter(page).at(it.target)) + + // if page numbering is without closing dot add it in the reference + if pn.last() != "." { + pn += "." + } + + // compose supplement + let supp = it.supplement + if it.supplement == auto { + supp = page.supplement + } + + link(it.target, box(pn + " " + supp)) + return + // + // Normal reference + // + } else { + // Headings + if it.element != none and it.element.func() == heading { + let nums = numbering( + it.element.numbering, + ..counter(heading).at(it.target), + ) + + let supp = it.supplement + if it.supplement == auto { + supp = it.element.supplement + } + + link(it.target, box(nums + " " + supp)) + return + } + + // Figures + if it.element != none and it.element.func() == figure { + let nums = numbering( + it.element.numbering, + ..it.element.counter.at(it.target), + ) + let supp = it.supplement + if it.supplement == auto { + if ( + it.element.kind == image + or it.element.kind == table + or it.element.kind == raw + ) { + supp = it.element.supplement + } else { + return it // for unknown types use their default setup + } + } + + link(it.target, box(nums + " " + supp)) + return + } + + // Equations + if it.element != none and it.element.func() == math.equation { + // numbering + let nums = numbering( + it.element.numbering, + ..counter(math.equation).at(it.target), + ) + + // supplement + let supp = it.supplement + if it.supplement == auto { + supp = conf.supplements.equation + } + + link(it.target, box(nums + " " + supp)) + return + } + } + it // ref: fallback to default + } + + // Add main content + it +} + +/// Referencia hivatkozás létrehozása megfelelő nagybetűs névelővel. +/// +/// ```example +/// #Aref() azt mutatja... +/// ``` +/// -> content +#let Aref( + /// A hivatkozni kívánt címke. -> label + target, + /// A hivatkozás típusa. -> "normal" | "page" + form: "normal", + /// Tetszőleges azonosító szöveg. -> none | auto | content | function + supplement: auto, +) = r.Aref(target, form: form, supplement: supplement) + +/// Referencia hivatkozás létrehozása megfelelő kisbetűs névelővel. +/// +/// ```example +/// Ahogy #aref()ben bemutattuk. +/// ``` +/// +/// -> content +#let aref( + /// A hivatkozni kívánt címke. -> label + target, + /// A hivatkozás típusa. -> "normal" | "page" + form: "normal", + /// Tetszőleges azonosító szöveg. -> none | auto | content | function + supplement: auto, +) = r.aref(target, form: form, supplement: supplement) + +/// Magyar tipográfiai szabályoknak megfelelő idézőjel. +/// +/// ```example +/// #hq[...#hq[...#hq[minta]...]...] +/// ``` +/// +/// -> content +#let hq( + /// A szöveg, amit idézőjelbe kell tenni. -> content + body, +) = q.hq(body) + +/// Referenciák magyar toldalékolása. +/// ```example +/// #told(, "es") +/// ``` +/// ```example +/// #told(, "es", form: "page") +/// ``` +/// -> content +#let told( + /// A toldalékolni kívánt elem. -> label + prefix, + /// Az első toldalék. -> str + rag, + /// A második toldalék. -> str | none + rag2: none, + /// A hivatkozás típusa. -> "normal" | "page" + form: "normal", + /// Tetszőleges azonosító szöveg. -> none | auto | content | function + supplement: auto, +) = t.told(prefix, rag, rag2: rag2, form: form, supplement: supplement) + +/// @cmd:Aref és @cmd:told kombinációja. +#let Atold(target, rag, rag2: none, form: "normal", supplement: auto) = { + r.anoref(target, form: form, supplement: "") + t.told(target, rag, rag2: rag2, form: form, supplement: supplement) +} + +/// @cmd:aref és @cmd:told kombinációja. +#let atold(target, rag, rag2: none, form: "normal", supplement: auto) = { + r.anoref(target, form: form, supplement: "") + t.told(target, rag, rag2: rag2, form: form, supplement: supplement) +} diff --git a/packages/preview/pannotyp/0.0.1/src/quote.typ b/packages/preview/pannotyp/0.0.1/src/quote.typ new file mode 100644 index 0000000000..b999023068 --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/src/quote.typ @@ -0,0 +1,35 @@ +// Proper Hungarian quotes based on nesting level. +// XXX: panic is not the right solution here... +#let _nest = counter("nesting") + +#let hq(body) = { + context { + let n = _nest.get().first() + _nest.step() + + if n == 0 { + "„" + } else if n == 1 { + "»" + } else if n == 2 { + "’" + } else { + panic("nesting is too deep") + } + + body + + if n == 0 { + "”" + } else if n == 1 { + "«" + } else if n == 2 { + "’" + } else { + panic("nesting is too deep") + } + + _nest.update(n => n - 1) + } +} + diff --git a/packages/preview/pannotyp/0.0.1/src/told.typ b/packages/preview/pannotyp/0.0.1/src/told.typ new file mode 100644 index 0000000000..280cc8bb71 --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/src/told.typ @@ -0,0 +1,278 @@ +#import "util.typ" + +#let ragok = ( + "a": ( + // 0 1 2 3 4 5 6 7 8 9 + ("a", "e", "a", "a", "e", "e", "a", "e", "a", "e"), + // X 11 12 13 14 15 16 17 18 19 + ("x", "e", "e", "a", "e", "e", "a", "e", "a", "e"), + // X 10 20 30 40 50 60 70 80 90 + ("x", "e", "a", "a", "e", "e", "a", "e", "a", "e"), + // ...... 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("x", "x", "a", "e", "e", "e", "a", "a", "a", "a"), + ), + "ad": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ad", "ed", "od", "ad", "ed", "öd", "od", "ed", "ad", "ed"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "ed", "ed", "ad", "ed", "öd", "od", "ed", "ad", "ed"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "ed", "ad", "ad", "ed", "ed", "ad", "ed", "ad", "ed"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "ad", "ed", "ed", "ed", "od", "od", "od", "ad"), + ), + "an": ( + // 0 1 2 3 4 5 6 7 8 9 + ("án", "en", "en", "an", "en", "en", "an", "en", "an", "en"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "en", "en", "an", "en", "en", "an", "en", "an", "en"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "en", "an", "an", "en", "en", "an", "en", "an", "en"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "an", "en", "en", "en", "n", "n", "n", "an"), + ), + "as": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ás", "es", "es", "as", "es", "ös", "os", "es", "as", "es"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "es", "es", "as", "es", "ös", "os", "es", "as", "es"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "es", "as", "as", "es", "es", "as", "es", "as", "es"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "as", "es", "es", "es", "s", "s", "s", "os"), + ), + "at": ( + // 0 1 2 3 4 5 6 7 8 9 + ("át", "et", "őt", "at", "et", "öt", "ot", "et", "at", "et"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "et", "őt", "at", "et", "öt", "ot", "et", "at", "et"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "et", "at", "at", "et", "et", "at", "et", "at", "et"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "at", "et", "et", "et", "t", "t", "t", "at"), + ), + "ba": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ba", "be", "be", "ba", "be", "be", "ba", "be", "ba", "be"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "be", "be", "ba", "be", "be", "ba", "be", "ba", "be"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "be", "ba", "ba", "be", "be", "ba", "be", "ba", "be"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "ba", "be", "be", "be", "ba", "ba", "ba", "ba"), + ), + "bol": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ból", "ből", "ből", "ból", "ből", "ből", "ból", "ből", "ból", "ből"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "ből", "ből", "ból", "ből", "ből", "ból", "ből", "ból", "ből"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "ből", "ból", "ból", "ből", "ből", "ból", "ből", "ból", "ből"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "ból", "ből", "ből", "ből", "ból", "ból", "ból", "ból"), + ), + "hoz": ( + // 0 1 2 3 4 5 6 7 8 9 + ("hoz", "hez", "höz", "hoz", "hez", "höz", "hoz", "hez", "hoz", "hez"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "hez", "höz", "hoz", "hez", "höz", "hoz", "hez", "hoz", "hez"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "hez", "hoz", "hoz", "hez", "hez", "hoz", "hez", "hoz", "hez"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "hoz", "hez", "hez", "hez", "hoz", "hoz", "hoz", "hoz"), + ), + "nal": ( + // 0 1 2 3 4 5 6 7 8 9 + ("nál", "nél", "nél", "nál", "nél", "nél", "nál", "nél", "nál", "nél"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "nél", "nél", "nál", "nél", "nél", "nál", "nél", "nál", "nél"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "nél", "nál", "nál", "nél", "nél", "nál", "nél", "nál", "nél"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "nál", "nél", "nél", "nél", "nál", "nál", "nál", "nál"), + ), + "nak": ( + // 0 1 2 3 4 5 6 7 8 9 + ("nak", "nek", "nek", "nak", "nek", "nek", "nak", "nek", "nak", "nek"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "nek", "nek", "nak", "nek", "nek", "nak", "nek", "nak", "nek"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "nek", "nak", "nak", "nek", "nek", "nak", "nek", "nak", "nek"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "nak", "nek", "nek", "nek", "nak", "nak", "nak", "nak"), + ), + "ra": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ra", "re", "re", "ra", "re", "re", "ra", "re", "ra", "re"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "re", "re", "ra", "re", "re", "ra", "re", "ra", "re"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "re", "ra", "ra", "re", "re", "ra", "re", "ra", "re"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "ra", "re", "re", "re", "ra", "ra", "ra", "ra"), + ), + "rol": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ról", "ről", "ről", "ról", "ről", "ről", "rol", "ről", "ról", "ről"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "ről", "ről", "ról", "ről", "ről", "rol", "ről", "ról", "ről"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "ről", "ról", "ról", "ről", "ről", "ról", "ről", "ról", "ről"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "ról", "ről", "ről", "ről", "ról", "ról", "ról", "ról"), + ), + "szor": ( + // 0 1 2 3 4 5 6 7 8 9 + // @typstyle off + ("szor", "szer", "ször", "szor", "szer", "ször", "szor", "szer", "szor", "szer"), + // X 11 12 13 14 15 16 17 18 19 + // @typstyle off + ("xxxx", "szer", "ször", "szor", "szer", "ször", "szor", "szer", "szor", "szer"), + // X 10 20 30 40 50 60 70 80 90 + // @typstyle off + ("xxxx", "szer", "szor", "szor", "szer", "szer", "szor", "szer", "szor", "szer"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + // @typstyle off + ("xxxx", "xxxx", "szor", "szer", "szer", "szer", "szor", "szor", "szor", "szor"), + ), + "tol": ( + // 0 1 2 3 4 5 6 7 8 9 + ("tól", "től", "től", "tól", "től", "től", "tol", "től", "tól", "től"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "től", "től", "tól", "től", "től", "tol", "től", "tól", "től"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "től", "tól", "tól", "től", "től", "tól", "től", "tól", "től"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "tól", "től", "től", "től", "tól", "tól", "tól", "tól"), + ), + "ul": ( + // 0 1 2 3 4 5 6 7 8 9 + ("ul", "ül", "ül", "ul", "ül", "ül", "ul", "ül", "ul", "ül"), + // X 11 12 13 14 15 16 17 18 19 + ("xx", "ül", "ül", "ul", "ül", "ül", "ul", "ül", "ul", "ül"), + // X 10 20 30 40 50 60 70 80 90 + ("xx", "ül", "ul", "ul", "ül", "ül", "ul", "ül", "ul", "ül"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xx", "xx", "ul", "ül", "ül", "ül", "ul", "ul", "ul", "ul"), + ), + "val": ( + // 0 1 2 3 4 5 6 7 8 9 + ("val", "gyel", "vel", "mal", "gyel", "tel", "tal", "tel", "cal", "cel"), + // X 11 12 13 14 15 16 17 18 19 + ("xxx", "gyel", "vel", "mal", "gyel", "tel", "tal", "tel", "cal", "cel"), + // X 10 20 30 40 50 60 70 80 90 + ("xxx", "zel", "szal", "cal", "nel", "nel", "nal", "nel", "nal", "nel"), + // 10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 10e8 10e9 + ("xxx", "xxx", "zal", "rel", "rel", "rel", "val", "val", "val", "dal"), + ), +) + +// Count trailing zeros +#let ctz(i) = { + if i == 0 { + return 0 + } + let ret = 0 + while calc.rem(i, 10) == 0 { + ret += 1 + i /= 10 + } + return ret +} + +#let told_get(i, r) = { + let z = ctz(i) + // trailing zeros + if z == 1 { + r.at(2).at(int(i / 10)) + } else if z > 1 { + r.at(3).at(z, default: "a") + } else { + // no trailing zeros + if i < 10 { + return r.at(0).at(i) + } + while i > 10 { + i = calc.rem(i, 10) + } + r.at(1).at(i) + } +} + +#let told_handler(i, rag) = { + if rag == "a" or rag == "e" { + told_get(i, ragok.a) + } else if rag == "ad" or rag == "ed" or rag == "öd" { + told_get(i, ragok.ad) + } else if rag == "adik" or rag == "edik" or rag == "ödik" { + told_get(i, ragok.ad) + "ik" + } else if rag == "an" or rag == "en" { + told_get(i, ragok.an) + } else if rag == "as" or rag == "es" or rag == "ös" { + told_get(i, ragok.as) + } else if rag == "at" or rag == "et" or rag == "ot" { + told_get(i, ragok.at) + } else if rag == "ba" or rag == "be" { + told_get(i, ragok.ba) + } else if rag == "ban" or rag == "ben" { + told_get(i, ragok.ba) + "n" + } else if rag == "ból" or rag == "ből" { + told_get(i, ragok.bol) + } else if rag == "hoz" or rag == "hez" or rag == "höz" { + told_get(i, ragok.hoz) + } else if rag == "nak" or rag == "nek" { + told_get(i, ragok.nak) + } else if rag == "nál" or rag == "nél" { + told_get(i, ragok.nal) + } else if rag == "ra" or rag == "re" { + told_get(i, ragok.ra) + } else if rag == "ról" or rag == "ről" { + told_get(i, ragok.rol) + } else if rag == "szor" or rag == "szer" or rag == "ször" { + told_get(i, ragok.szor) + } else if rag == "tól" or rag == "től" { + told_get(i, ragok.tol) + } else if rag == "ul" or rag == "ül" { + told_get(i, ragok.ul) + } else if rag == "val" or rag == "vel" { + told_get(i, ragok.val) + } else { + panic("told: ismeretlen rag", rag) + } +} + +#let told(target, rag, rag2: none, form: "normal", supplement: auto) = { + context { + let ld = util.getLabelData(target, form: form) + let i = ld.counter.last() + + if i != none and i > 1000000000 { + panic("told: counter is too big") + } + + // generate t1 and t2 + let t1 = told_handler(i, rag) + let t2 = "" + if rag2 != none { + t2 = told_handler(i, rag2) + } + + // supplement + let supp = supplement + if supplement == auto { + supp = ld.supplement + if form == "page" { + supp = page.supplement + } + } + + return ( + link( + target, + box(numbering(ld.numbering, ..ld.counter) + "-" + t1 + t2) + " " + supp, + ) + ) + } +} diff --git a/packages/preview/pannotyp/0.0.1/src/util.typ b/packages/preview/pannotyp/0.0.1/src/util.typ new file mode 100644 index 0000000000..813bd7864b --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/src/util.typ @@ -0,0 +1,69 @@ +#import "@preview/valkyrie:0.2.2" as v + +#let getLabelCounterFirst(label) = { + // array of matches for this label + let matches = query(label) + if matches.len() == 0 { + panic("PannoTyp: label not found") + } else { + // label found + let el = matches.first() // there should be only one match anyway + if el.func() == heading { + return counter(heading).at(label).first() + } else if el.func() == math.equation { + return counter(math.equation).at(label).first() + } else { + return el.counter.at(label).first() + } + } +} + +#let LabelData = v.dictionary(( + counter: v.array(), + numbering: v.either(v.string(), v.function()), + supplement: v.content(), +)) + +#let getLabelData(label, form: "normal") = { + // array of matches for this label + let matches = query(label) + if matches.len() == 0 { + panic("PannoTyp: label not found") + } else { + // label found + let el = matches.first() // there should be only one match anyway + + // counter + let cnt = none + if form == "page" { + cnt = counter(page).at(label) + } else { + if el.func() == heading { + cnt = counter(heading).at(label) + } else if el.func() == math.equation { + cnt = counter(math.equation).at(label) + } else { + cnt = el.counter.at(label) + } + } + + // numbering + let nbring = el.numbering + if form == "page" { + if page.numbering == none { + nbring = "1" + } else { + nbring = page.numbering + } + } + + return v.parse( + ( + counter: cnt, + numbering: nbring, + supplement: el.supplement, + ), + LabelData, + ) + } +} diff --git a/packages/preview/pannotyp/0.0.1/typst.toml b/packages/preview/pannotyp/0.0.1/typst.toml new file mode 100644 index 0000000000..ec355ffd64 --- /dev/null +++ b/packages/preview/pannotyp/0.0.1/typst.toml @@ -0,0 +1,11 @@ +[package] +name = "pannotyp" +version = "0.0.1" +entrypoint = "src/panno.typ" +authors = ["VÖRÖSKŐI András "] +license = "CC0-1.0" +description = "Hungarian language support: captions, quotes, helper functions." +repository = "https://codeberg.org/voroskoi/PannoTyp" +keywords = ["language", "hungarian", "magyar"] +categories = ["languages"] +exclude = ["manifest.scm", "docs/"]