Skip to content

Commit

Permalink
Merge pull request #1854 from tbrowder/fix-gh1852
Browse files Browse the repository at this point in the history
Fix for GH #1852: pod converts non-breaking space into normal space
  • Loading branch information
lizmat committed May 21, 2018
2 parents 791c3e3 + 662f19e commit 4cbb0fa
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Perl6/Pod.nqp
Expand Up @@ -397,12 +397,13 @@ class Perl6::Pod {
}

our sub normalize_text($a) {
# given a string of text, possibly including newlines, reduces
# contiguous whitespace to a single space and trims leading and
# trailing whitespace from all logical lines
my $r := subst($a, /\s+/, ' ', :global);
$r := subst($r, /^^\s*/, '');
$r := subst($r, /\s*$$/, '');
# Given a string of text, possibly including newlines, reduces
# contiguous whitespace (tabs and normal spaces) to a single space and trims leading and
# trailing whitespace from all logical lines.
# Note that embedded, non-breaking whitespace is not affected.
my $r := subst($a, /[ ' ' | \t ]+/, ' ', :global);
$r := subst($r, /^^\s*/, ''); # trim all leading spaces
$r := subst($r, /\s*$$/, ''); # trim all trailing spaces
return $r;
}

Expand Down Expand Up @@ -454,15 +455,18 @@ class Perl6::Pod {
}

# Takes an array of arrays of pod characters (normal character or
# formatting code) returns an array of strings and formatting codes
# formatting code) returns an array of strings and formatting codes.
our sub build_pod_strings(@strings) {
my $in_code := $*POD_IN_CODE_BLOCK;

sub push_chars(@chars, @where) {
if @chars {
my $s := nqp::join('', @chars);
if ! $in_code {
$s := subst($s, /\s+/, ' ', :global);
# Note that embedded, non-breaking whitespace is
# not affected: we only collapse tabs and normal
# spaces (' ') to a single space.
$s := subst($s, /[ ' ' | \t ]+/, ' ', :global);
}
$s := $*W.add_constant('Str', 'str', $s).compile_time_value;
@where.push($s);
Expand Down

0 comments on commit 4cbb0fa

Please sign in to comment.