创建新书目时遇到的问题

创建新书目时遇到的问题

我开始着手解决git变更日志自动排版的问题,使用biblatexbiber作为帮助,但我很难理解自己在做什么以及如何biblatex很好地构建控件。

这是我目前得到的结果。很抱歉,MWE 没有小一点;我差点因此得了疝气:

mwe111.tex:

\documentclass{article} 
\usepackage[%
    datamodel=gitlog,
    bibstyle=gitlog,
    sorting=none,
    date=iso8601,
    firstinits=true,
]{biblatex}
\addbibresource{mwe111.gll}
\begin{document}
\nocite{*}
\printbibliography[title={Change Log},type=gitcommit]
\end{document}

mwe111.gll:

@gitcommit{9dce109,
 author = {Brent Longborough},
 date = {2015-11-15},
 title = {Initial commit
},
 commithash = {9dce10970bb6be976ce59f76dd28e52abeb3b103} }
@gitcommit{f558cdd,
 author = {Brent Longborough},
 date = {2015-11-15},
 title = {First code to build pseudo-bibfile
},
 commithash = {f558cddc5a95acb1c081ead6f6e81cb9941941a0} }
@gitcommit{240f4c9,
 author = {Brent Longborough},
 date = {2015-11-15},
 title = {Added data model (not working) - now we step back a bit
},
 commithash = {240f4c9dbb22631f6098fbe45c409ef58cdddb09} }
@gitcommit{b4629f6,
 author = {Brent Longborough},
 date = {2015-11-16},
 title = {First working version full of restrictions
},
 commithash = {b4629f6bb7504b2d6e4a677294a761e1d1d5c659} }
@gitcommit{d651d24,
 author = {Brent Longborough},
 date = {2015-11-17},
 title = {Gradually improving things (especially understanding)
},
 commithash = {d651d249a3a14fd270a0f40e5d8124f6c552cc5b} }
@gitcommit{4c1dd2c,
 author = {Brent Longborough},
 date = {2015-11-17},
 title = {Making an MWE for TeX.SX
},
 commithash = {4c1dd2c540ff8a2f2976d972d15071c1f54f9379} }

gitlog.dbx:

\DeclareDatamodelEntrytypes{gitcommit}
\DeclareDatamodelFields[type=field,datatype=literal]{
  title,
  commithash
}
\DeclareDatamodelFields[type=field,datatype=name]{
  author
}
\DeclareDatamodelFields[type=field, datatype=date]{
  date
}
\DeclareDatamodelEntryfields[gitcommit]{
  title,
  author,
  date,
  commithash
}

gitlog.bbx:

\ProvidesFile{gitlog.bbx}
[\abx@bbxid]

\defbibenvironment{bibliography}
  {\list
     {\printfield{entrykey}}
     {\setlength{\labelwidth}{0pt}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{%
    \hspace\labelsep\ttfamily##1}}}
  {\endlist}
  {\item}

\newbibmacro*{begentry}{}
\newbibmacro*{finentry}{\finentry}

\DeclareBibliographyDriver{gitcommit}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{title}%
  \newblock%
  \usebibmacro{author}%
  \newunit
  \usebibmacro{date}%
  \newunit
  \usebibmacro{commithash}
  \usebibmacro{finentry}}

\newbibmacro*{commithash}{%
    \printtext{%
       \printfield{commithash}%
}}

\endinput

现在,到目前为止这类工作(排版很糟糕,但这不是现阶段的重要问题),除了没有打印“commithash”字段:

git changelog-排版输出

显然我一定漏掉了一些重要的东西,但不知道是什么。有人能帮忙吗?

答案1

似乎biblatex/Biber 对空格和标点符号有点敏感\DeclareDatamodelFieldsbiblatex文档在解释中警告\DeclareDatamodelFields(第 160 页)

与 TeX csv 列表中一样,确保每个元素后面紧跟着一个逗号或右括号 - 没有多余的空格。

如果我在字段名称后添加逗号,一切都会按预期进行。

您会发现,不需要声明诸如datetitle和之类的标准字段author,这些字段已经存在了。

工作gitlog.dbx可能是

\DeclareDatamodelEntrytypes{gitcommit}
\DeclareDatamodelFields[type=field,datatype=literal]{
  commithash,
}
\DeclareDatamodelEntryfields[gitcommit]{
  title,
  author,
  date,
  commithash,
}

相关内容