Outputting custom types in MKiv bibliography

Hello, I’m trying to create my first publication using ConTeXt mkiv. All going well except for the bibliography formatting. Previously I have used LaTeX, standard entry types in BibTeX, and custom output formats using Biblatex. My publication cites lots of historical sources, viz.: (1) Newspaper articles — currently stored as ‘article’ types in BibTex. (2) Archival sources (historic letter, some leather-bound volume, a catalogued box of old photographs, etc.) — currently stored as ‘unpublished’ or ‘misc'. I would prefer to store these (in BibTeX, buffer, lua, or xml) as custom types (eg. ‘newspaper’, ‘archivalItem’), create setups for how they are output and which fields I output. I found a ’newspaper’ type (and other non-BibTeX types) defined in publ-imp-apa.mkiv as: \startsetups btx:apa:list:newspaper \fastsetup{btx:apa:list:article} \stopsetups I hoped this would mean I could output something: Boxing. (1903, September 13). The Sunday Times, p.8 However, if I create an item of type 'newspaper’ and \cite it I get an output of all stored fields: newspaper: [day: 13] [journal: {The Sunday Times}] [month: 09] [pages:8][title: {Boxing.}] [type: newspaper article] [year: 1903] A similar thing happens if I try to cite the standard BibTeX type ‘misc’. If I store the newspaper item as type ‘article’ I get: “Boxing.”, The Sunday Times, 8, 1903. (missing day and month) Is it relevant that there is a problem when I include \showbtxfields[rotation=30] in my document? The resulting table has ‘*’ for fields in ‘article’, ‘book’, ‘demo-a’, ‘demo-b’ but the columns for ‘newspaper’ and ‘misc’ are empty. Any pointers gratefully received. Cheers, Mike O’Connor P.S. I am working in TeXShop on OSX (10.11.3), and it reports: This is LuaTeX, Version beta-0.80.0 (TeX Live 2015) (rev 5238) ConTeXt ver: 2015.05.18 12:26 MKIV current fmt: 2016.3.19 int: english/english

G’Day, Having a first go at converting TEI XML to ConTeXt. Steep learning curve, but easier (for me) than XSLT, and first results were amazing. Using http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf as a guide. Currently stuck on converting an ISO format date (eg. 1908-01-10) into something more readable (eg. 10 January 1908) in the output. I presume I should create a function (?luacode) that can take any ISO value and output the readable form. The following works but seems to me inefficient. Grateful for any pointers. Mike Here is my MWE: \startbuffer[demo] <TEI> <text> <body> <div type="letter"> <opener> <date when-iso="1908-01-10" type="divDate">10.I.08</date> </opener> <closer> <date when-iso="1908-03-19" type="secondDate">19 Mar '08</date> </closer> </div> </body> </text> </TEI> \stopbuffer \startxmlsetups xml:initialize \xmlsetsetup{#1}{date}{xml:date} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:date \xmldoifelse {#1}{.[@type='divDate']} { \def\docdate{\ctxlua{ local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4) local tmonth = string.sub('\xmlatt{#1}{when-iso}',6,7) local tday = string.sub('\xmlatt{#1}{when-iso}',9,10) context.date{d = tday, m = tmonth, y = tyear} }} \docdate[day,month,year] = Document Date \par } { \def\docdate{\ctxlua{ local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4) local tmonth = string.sub('\xmlatt{#1}{when-iso}',6,7) local tday = string.sub('\xmlatt{#1}{when-iso}',9,10) context.date{d = tday, m = tmonth, y = tyear} }} \docdate[day,month,year] = Event Date\par } \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext

On 8/15/2018 12:27 PM, Mike O'Connor wrote:
\startluacode function xml.finalizers.tex.MyDate(e,what,how) local t = string.split(e[1].at[what],"-") context.date( { y = t[1], m = t[2], d = t[3] }, { how } ) end \stopluacode \startxmlsetups xml:date \xmldoifelse {#1}{.[@type='divDate']} { \xmlfilter{#1}{./MyDate("when-iso","day,month,year")}\ Document Date \par } { \xmlfilter{#1}{./MyDate("when-iso","day,month,year")}\ Event Date\par } \stopxmlsetups ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

I couldn’t get this to work. Had to change it to: \startluacode function xml.finalizers.tex.MyDate(e,what,how) local ee = e[1].at[what] local t = (string.split(ee,"-")) context.date( { y = t[1], m = t[2], d = t[3] }, { how } ) end \stopluacode mtx-context | ConTeXt Process Management 1.03 mtx-context | mtx-context | main context file: /Volumes/Macintosh HD/usr/local/texlive/context-109/tex/texmf-context/tex/context/base/mkiv/context.mkiv mtx-context | current version: 2020.01.30 14:13 mtx-context | main context file: /Volumes/Macintosh HD/usr/local/texlive/context-109/tex/texmf-context/tex/context/base/mkiv/context.mkxl mtx-context | current version: 2020.01.30 14:13 Greetings Axel

On 3/11/2020 2:14 PM, Axel Kielhorn wrote:
You mean the () around the split? weird. Anyway, there's also a time splitter (dedicated to Alan who needed one): print(os.time(utilities.parsers.totime("2019-03-05 12:12:12"))) print(os.time(utilities.parsers.totime("2019/03/05 12:12:12"))) print(os.time(utilities.parsers.totime("05-03-2019 12:12:12"))) print(os.time(utilities.parsers.totime("05/03/2019 12:12:12"))) inspect(utilities.parsers.totime("2019-03-05 12:12:12")) inspect(utilities.parsers.totime("2019/03/05 12:12:12")) inspect(utilities.parsers.totime("05-03-2019 12:12:12")) inspect(utilities.parsers.totime("05/03/2019 12:12:12")) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Axel Kielhorn
-
Hans Hagen
-
luigi scarso
-
Mike O'Connor