Skip to content

Commit ec5919a

Browse files
committed
em-space before span
1 parent d966cf3 commit ec5919a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

typography.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt Apache-2.0
22
// (the above comment is for LibreJS)
33

4-
// Web page typography helper v1.4 (c) 2011-2014,2016,2019-2020 Silas S. Brown.
4+
// Web page typography helper v1.5 (c) 2011-2014,2016,2019-2021 Silas S. Brown.
55

66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -101,7 +101,12 @@ if(document.getElementsByTagName && navigator.userAgent.indexOf("Googlebot/")==-
101101
}
102102
break;
103103
case 3: // text
104-
var v=c.nodeValue; var v2=typefix(v); if(v2!=v) c.nodeValue=v2;
104+
var v=c.nodeValue;
105+
var followed = c.nextSibling && c.nextSibling.nodeType==1 && ["span","a"].includes(c.nextSibling.nodeName.toLowerCase());
106+
if (followed) v += "A"; // so can match 'end of sentence. <span>More...' (TODO: should we check there is indeed a capital at start of span or anchor?)
107+
var v2=typefix(v);
108+
if (followed) v2=v2.slice(0,-1); // rm "A"
109+
if(v2!=v) c.nodeValue=v2;
105110
}
106111
c=c.nextSibling;
107112
}

0 commit comments

Comments
 (0)