summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/bibtex/bibhtml/detex.sed
blob: 72395862fb59bb1a2a335eac88144ead84d37b9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Edit TeXisms in the .bbl output, to make it HTML-ready
# From bibhtml release 2.0.2, of 2013 September 8.
# Hg node 7076ce83a035.
# See http://purl.org/nxg/dist/bibhtml

# Remove %\n line-breaks added by BibTeX
/% *$/{
  :a
  N
  s/% *\n//
  t a
}

# Escape ampersands
s,&,&,g

# Process DOI:{...} lines, escaping '<' characters in DOIs and rearranging into a <a> element
# (the substitutions below probably rely on the "DOI:" being at the beginning of a line).
# First, turn DOI:{X} into DOI:{X|X}
/^ *DOI/s,DOI:{\([^}]*\)},DOI:{\1|\1},
# Escape the two DOIs differently...
#    ...first do URL escaping
#    ...then do HTML/XML escaping
/^ *DOI:/{
  :bx
  s,\([^<|]*\)<\([^|]*\)|,\1%3C\2|,
  t bx
  :cx
  s,\([^<}]*\)<\([^}]*\)},\1\&lt;\2},
  t cx
}
# ...and then turn the result into a <a> element
/^ *DOI:{/s,DOI:{\([^|]*\)|\([^}]*\)},doi:<a href='http://dx.doi.org/\1'><code>\2</code></a>,

# Get rid of TeX braces (I hope there aren't any of these in DOIs or other URLs)
s/[{}]//g

# Replace '~' ties with spaces, as lont as they aren't URL ".../~user"
s,\([^/]\)~,\1 ,g
# ...and '\ ' with plain space
s,\\ , ,g

# accented characters
s,\\'a,á,g
s,\\'e,é,g
s,\\`e,è,g
s,\\^o,ô,g
s+\\,c+ç+g
s,\\ss,ß,g
s,\\"a,ä,g
s,\\"o,ö,g
s,\\"u,ü,g
# We could include the following substitution, but I'm nervous of that,
# because I'm not positive that "--" can't legitimately appear in DOIs
# (the above substitutions are also in principle illegitimate for the same reason,
# but they seem safely unlikely).
#s,--,–,