Debian Codegraph @

texmf-dist/doc/bibtex/bibhtml/detex.sed

raw
1 # Edit TeXisms in the .bbl output, to make it HTML-ready
2 # From bibhtml release 2.0.2, of 2013 September 8.
3 # Hg node 7076ce83a035.
4 # See http://purl.org/nxg/dist/bibhtml
5
6 # Remove %\n line-breaks added by BibTeX
7 /% *$/{
8 :a
9 N
10 s/% *\n//
11 t a
12 }
13
14 # Escape ampersands
15 s,&,&,g
16
17 # Process DOI:{...} lines, escaping '<' characters in DOIs and rearranging into a <a> element
18 # (the substitutions below probably rely on the "DOI:" being at the beginning of a line).
19 # First, turn DOI:{X} into DOI:{X|X}
20 /^ *DOI/s,DOI:{\([^}]*\)},DOI:{\1|\1},
21 # Escape the two DOIs differently...
22 # ...first do URL escaping
23 # ...then do HTML/XML escaping
24 /^ *DOI:/{
25 :bx
26 s,\([^<|]*\)<\([^|]*\)|,\1%3C\2|,
27 t bx
28 :cx
29 s,\([^<}]*\)<\([^}]*\)},\1\&lt;\2},
30 t cx
31 }
32 # ...and then turn the result into a <a> element
33 /^ *DOI:{/s,DOI:{\([^|]*\)|\([^}]*\)},doi:<a href='http://dx.doi.org/\1'><code>\2</code></a>,
34
35 # Get rid of TeX braces (I hope there aren't any of these in DOIs or other URLs)
36 s/[{}]//g
37
38 # Replace '~' ties with spaces, as lont as they aren't URL ".../~user"
39 s,\([^/]\)~,\1 ,g
40 # ...and '\ ' with plain space
41 s,\\ , ,g
42
43 # accented characters
44 s,\\'a,á,g
45 s,\\'e,é,g
46 s,\\`e,è,g
47 s,\\^o,ô,g
48 s+\\,c+ç+g
49 s,\\ss,ß,g
50 s,\\"a,ä,g
51 s,\\"o,ö,g
52 s,\\"u,ü,g
53 # We could include the following substitution, but I'm nervous of that,
54 # because I'm not positive that "--" can't legitimately appear in DOIs
55 # (the above substitutions are also in principle illegitimate for the same reason,
56 # but they seem safely unlikely).
57 #s,--,–,