codeSpanContent function
The content of a code span, normalised the CommonMark way: line endings
become spaces, and one space is stripped from each end when both ends have
one and the content is not all spaces — which is what lets
`` `a` `` hold a backtick at its edge.
Implementation
String codeSpanContent(String raw) {
var s = raw.contains('\n') ? raw.replaceAll('\n', ' ') : raw;
if (s.length >= 2 &&
s.codeUnitAt(0) == _space &&
s.codeUnitAt(s.length - 1) == _space &&
s.trim().isNotEmpty) {
s = s.substring(1, s.length - 1);
}
return s;
}