Debian Codegraph @

markup/pandoc/convert_integration_test.go

raw
1 // Copyright 2026 The Hugo Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package pandoc_test
15
16 import (
17 "testing"
18
19 "github.com/gohugoio/hugo/hugolib"
20 "github.com/gohugoio/hugo/markup/pandoc"
21 )
22
23 // See issue 15062.
24 func TestBibliographySupport(t *testing.T) {
25 if !pandoc.Supports() {
26 t.Skip("pandoc not installed")
27 }
28 t.Parallel()
29
30 files := `
31 -- hugo.toml --
32 disableKinds = ['home','rss','section','sitemap','taxonomy','term']
33 [security.exec]
34 allow = ['pandoc']
35 -- layouts/page.html --
36 {{ .Content }}
37 -- content/p1.pdc --
38 ---
39 title: home
40 ---
41
42 ---
43 bibliography: testdata/foo.bib
44 citation-style: testdata/ieee.csl
45 link-citations: true
46 references:
47 - type: article-journal
48 id: WatsonCrick1953
49 author:
50 - family: Watson
51 given: J. D.
52 - family: Crick
53 given: F. H. C.
54 issued:
55 date-parts:
56 - - 1953
57 - 4
58 - 25
59 title: 'Molecular structure of nucleic acids: a structure for deoxyribose nucleic acid'
60 title-short: Molecular structure of nucleic acids
61 container-title: Nature
62 volume: 171
63 issue: 4356
64 page: 737-738
65 DOI: 10.1038/171737a0
66 ---
67
68 This is a citation: @einstein1905physics
69
70 This is another citation: [@WatsonCrick1953, p. 33]
71 `
72
73 b := hugolib.Test(t, files)
74
75 b.AssertFileContent("public/p1/index.html",
76 `<p>This is a citation: <span class="citation"
77 data-cites="einstein1905physics"><a href="#ref-einstein1905physics"
78 role="doc-biblioref">[1]</a></span></p>
79 <p>This is another citation: <span class="citation"
80 data-cites="WatsonCrick1953"><a href="#ref-WatsonCrick1953"
81 role="doc-biblioref">[2, p. 33]</a></span></p>
82 <div id="ref-einstein1905physics" class="csl-entry" role="listitem">
83 <div class="csl-left-margin">[1] </div><div class="csl-right-inline">A.
84 Einstein, <span>“Zur elektrodynamik bewegter
85 k<span>ö</span>rper,”</span> <em>Annalen der Physik</em>, vol. 322, no.
86 10, pp. 891–921, 1905.</div>
87 </div>
88 <div id="ref-WatsonCrick1953" class="csl-entry" role="listitem">
89 <div class="csl-left-margin">[2] </div><div class="csl-right-inline">J.
90 D. Watson and F. H. C. Crick, <span>“Molecular structure of nucleic
91 acids: a structure for deoxyribose nucleic acid,”</span>
92 <em>Nature</em>, vol. 171, no. 4356, pp. 737–738, Apr. 1953, doi: <a
93 href="https://doi.org/10.1038/171737a0">10.1038/171737a0</a>.</div>
94 </div>
95 </div>`,
96 )
97 }