zotero-chinese / website

Zotero 中文社区官方网站源码 | Source code for website of Zotero Chinese community
https://zotero-chinese.com
MIT License
3 stars 2 forks source link

`second-field-align="flush"` 对齐的宽度问题 #48

Closed zepinglee closed 1 month ago

zepinglee commented 1 year ago

https://zotero-cn.github.io/styles/manual-of-legal-citation-multi-lingual/

Screen Shot 2022-08-22 at 21 50 34

目前 display: flex 的对齐方式似乎是,每条文献的 label 与内容空固定的距离(0.5 em)。但是当 label 的宽度变化时(比如这里从 9 到 10),右侧内容在整体上就没有对齐了。

更理想的显示效果是,所有 label 使用固定的宽度,即所有 label 宽度的最大值。这样可以使得全部文献右侧内容都对齐。

Screen Shot 2022-08-22 at 21 56 09

citeproce.makeBibliography() 返回的第一个参数有个 maxoffset 表示 label 的最大字符数,应该可以用于计算 label 的宽度。对于目前的样式,(maxoffset / 2 + 1) em 是个比较合适的值,可以装下 〔10〕 这样使用全角六角括号的 label。

northword commented 1 year ago

收到。

还有一个相关的问题,有些样式设置了 fulsh,但输出的参考文献表里并没有将引注编号单独放在一个<div>里,例如中南财经政法大学学位论文的 citeproce.makeBibliography() 返回值为:

// src\zhongnan-university-of-economics-and-law-thesis\zhongnan-university-of-economics-and-law-thesis.csl
[{
  maxoffset: 5,
  entryspacing: 0,
  linespacing: 1,
  'second-field-align': 'flush',
  entry_ids: [
    [ 'gbt7714.04.2.2:05' ],
    [ 'gbt7714.A.01:10' ],
    [ 'gbt7714.04.4.2:05' ],
    [ 'gbt7714.04.6.2:01' ],
    [ 'gbt7714.04.6.2:03' ],
    [ 'gbt7714.04.1.2:17' ],
    [ 'gbt7714.A.07:08' ],
    [ 'gbt7714.04.4.2:09' ]
  ],
  bibliography_errors: [],
  done: false,
  bibstart: '<div class="csl-bib-body">\n',
  bibend: '</div>'
},
[
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[1] 贾东琴, 柯平. 面向数字素养的高校图书馆数字服务体系研究[C]. 中国图书馆学会, 编//中国图书馆学会年会论文集, 北京: 国家图书馆出版社, 2011: 45–52.</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[2] 库恩. 科学革命的结构: 第 4 版[M]. 金吾伦, 胡新和, 译. 2 版. 北京: 北京大学出版社, 2012.</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[3] 武丽丽, 华一新, 张亚军, 刘英敏. “北斗一号”监控管理网设计与实现[J]. 测绘科学, 2008, 33(5): 8–9.</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[4] 中国互联网络信息中心. 第 29 次中国互联网络发展现状统计报告[R]. .</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[5] Bawden D. Origins and concepts of digital Literacy[EB](2008-05-04).</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[6] Fan X, Sommers C H. Food irradiation research and Technology[M]. 2 edition. Ames, Iowa: Blackwell Publishing, 2013: 25–26.</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[7] Fourney M E. Advances in holographic Photoelasticity[C]//Symposium on Applications of Holography in Mechanics, New York: ASME, c1971: 17–38.</div></div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[8] Myburg A A, Grattapaglia D, Tuskan G A, Hellsten U, Hayes R D, Grimwood J, Jenkins J, Lindquist E, Tice H, Bauer D, Goodstein D M, Dubchak I, Poliakov A, Mizrachi E, Kullan A R K, Hussey S G, Pinard D, van der Merwe K, Singh P, van Jaarsveld I, et al. The genome of eucalyptus Grandis[J]. Nature, 2014, 510: 356–362.</div></div>\n'
]]

我观察了一下,这一类样式文件多有一个特点:把 citation-number 和后面的参考文献信息一起包在了一个宏里:

  <macro name="bib-entry-zh">
    <text variable="citation-number" prefix="[" suffix="] "/>
    <text macro="author" suffix=". "/>
    <text macro="title"/>
    ...
  </macro>

  <bibliography entry-spacing="0" et-al-min="21" et-al-use-first="20" second-field-align="flush">
    <sort>
      <key macro="author"/>
      <key macro="issued-year"/>
    </sort>
    <layout locale="en">
      <text macro="bib-entry-en" suffix="."/>
    </layout>
    <layout>
      <text macro="bib-entry-zh" suffix="."/>
    </layout>
  </bibliography>

而正常输出为

// src\gb-t-7714-2015-numeric-bilingual\gb-t-7714-2015-numeric-bilingual.csl
[{
  maxoffset: 3,
  entryspacing: 0,
  linespacing: 1,
  'second-field-align': 'flush',
  entry_ids: [
    [ 'gbt7714.A.01:10' ],
    [ 'gbt7714.04.1.2:17' ],
    [ 'gbt7714.04.2.2:05' ],
    [ 'gbt7714.A.07:08' ],
    [ 'gbt7714.04.4.2:05' ],
    [ 'gbt7714.04.4.2:09' ],
    [ 'gbt7714.04.6.2:01' ],
    [ 'gbt7714.04.6.2:03' ]
  ],
  bibliography_errors: [],
  done: false,
  bibstart: '<div class="csl-bib-body">\n',
  bibend: '</div>'
},[
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[1]</div><div class="csl-right-inline">库恩. 科学革命的结构: 第 4 版[M]. 金吾伦, 胡新和, 译. 2 版. 北京: 北京大学出版社, 2012.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[2]</div><div class="csl-right-inline">FAN X, SOMMERS C H. Food irradiation research and technology[M/OL]. 2nd ed. Ames, Iowa: Blackwell Publishing, 2013: 25-26[2014-06-26]. <a href="http://onlinelibrary.wiley.com/doi/10.1002/9781118422557.ch2/summary">http://onlinelibrary.wiley.com/doi/10.1002/9781118422557.ch2/summary</a>.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[3]</div><div class="csl-right-inline">贾东琴, 柯平. 面向数字素养的高校图书馆数字服务体系研究[C]//中国图书馆学会. 中国图书馆学会年会论文集: 2011 年卷. 北京: 国家图书馆出版社, 2011: 45-52.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[4]</div><div class="csl-right-inline">FOURNEY M E. Advances in holographic photoelasticity[C]//Symposium on Applications of Holography in Mechanics, August 23–25, 1971, University of Southern California, Los Angeles, California. New York: ASME, c1971: 17-38.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[5]</div><div class="csl-right-inline">武丽丽, 华一新, 张亚军, 等. “北斗一号”监控管理网设计与实现[J/OL]. 测绘科学, 2008, 33(5): 8-9[2009-10-25]. <a href="http://vip.calis.edu.cn/CSTJ/Sear.dll?OPAC_CreateDetail">http://vip.calis.edu.cn/CSTJ/Sear.dll?OPAC_CreateDetail</a>. DOI:<a href="https://doi.org/10.3771/j.issn.1009-2307.2008.05.002">10.3771/j.issn.1009-2307.2008.05.002</a>.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[6]</div><div class="csl-right-inline">MYBURG A A, GRATTAPAGLIA D, TUSKAN G A, et al. The genome of eucalyptus grandis[J/OL]. Nature, 2014, 510: 356-362[2014-06-25]. <a href="http://www.nature.com/nature/journal/v510/n7505/pdf/nature13308.pdf">http://www.nature.com/nature/journal/v510/n7505/pdf/nature13308.pdf</a>. DOI:<a href="https://doi.org/10.1038/nature13308">10.1038/nature13308</a>.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[7]</div><div class="csl-right-inline">中国互联网络信息中心. 第 29 次中国互联网络发展现状统计报告[R/OL]. (2012-01-16)[2013-03-26]. <a href="http://www.cnnic.net.cn/hlwfzyj/hlwxzbg/201201/P020120709345264469680">http://www.cnnic.net.cn/hlwfzyj/hlwxzbg/201201/P020120709345264469680</a>.</div>\n' +
    '  </div>\n',
  '  <div class="csl-entry">\n' +
    '    <div class="csl-left-margin">[8]</div><div class="csl-right-inline">BAWDEN D. Origins and concepts of digital literacy[EB/OL]. (2008-05-04)[2013-03-08]. <a href="http://www.soi.city.ac.uk/~dbawden/digital%20literacy%20chapter.pdf">http://www.soi.city.ac.uk/~dbawden/digital%20literacy%20chapter.pdf</a>.</div>\n' +
    '  </div>\n'
]]
  <bibliography entry-spacing="0" et-al-min="4" et-al-use-first="3" second-field-align="flush">
    <layout suffix="." locale="en">
      <text variable="citation-number" prefix="[" suffix="]"/>
      <text macro="entry-layout"/>
    </layout>
    <layout suffix=".">
      <text variable="citation-number" prefix="[" suffix="]"/>
      <text macro="entry-layout"/>
    </layout>
  </bibliography>

而且中南财经政法这个 maxoffset 不应该是 5 才对,因为最大的 [8] 也只有 4 (方括号右侧有一个空格)。

不知道这种是特性还是问题?

zepinglee commented 1 year ago

对,second-field-align="flush" 要求 bibliography > layout 有至少两个 elements。

https://github.com/zotero-cn/styles/blob/c17fea7f0cebdf6b3c17cc05daa0ec3e0fcbd552/src/zhongnan-university-of-economics-and-law-thesis/zhongnan-university-of-economics-and-law-thesis.csl#L332-L334

northword commented 1 month ago

此 issue 仍有问题,待修复:

image