Permalink
Browse files

Do E<> properly.

The @contents should contain the actual sequences, with the actual codes
used in the E<> being stored correspondingly in @meta in case the Pod
formatter needs it
  • Loading branch information...
1 parent 02329b9 commit eff1c27b79eb1edb0520b627fb560e2cadffd07d @Mouq Mouq committed Mar 5, 2014
Showing with 291 additions and 15 deletions.
  1. +1 −8 lib/Pod/To/Text.pm
  2. +24 −0 src/Perl6/Actions.nqp
  3. +10 −7 src/Perl6/Grammar.nqp
  4. +256 −0 src/Perl6/Pod.nqp
View
@@ -121,15 +121,8 @@ my %formats = {
"R" => "inverse"
};
-my %only_first_part := bag <D X L>;
-
sub formatting2text($pod) {
- my $text = twine2text($pod.content);
- if $pod.type ~~ %only_first_part {
- if $text ~~ /'|'/ {
- $text = $/.prematch
- }
- }
+ my $text = $pod.content>>.&pod2text.join;
if $pod.type ~~ %formats {
return colored($text, %formats{$pod.type});
}
View
@@ -685,6 +685,30 @@ class Perl6::Actions is HLL::Actions does STDActions {
method pod_formatting_code($/) {
if $<code> eq 'V' {
make ~$<content>;
+ } elsif $<code> eq 'E' {
+ my @content := [];
+ my @meta := [];
+ for $/[0] {
+ if $_<html_ref> {
+ my $s := Perl6::Pod::str_from_entity(~$_);
+ $s ?? @content.push($s) && @meta.push(~$_)
+ !! $/.CURSOR.worry("\"$_\" is not a valid HTML5 entity.");
+ } else {
+ my $n := $_<integer>
+ ?? $_<integer>.made
+ !! nqp::codepointfromname(~$_);
+ $n >= 0 ?? @content.push(nqp::chr($n)) && @meta.push(~$_)
+ !! $/.CURSOR.worry("\"$_\" is not a valid Unicode character name or code point.");
+ }
+ }
+ @content := Perl6::Pod::serialize_aos(@content).compile_time_value;
+ @meta := Perl6::Pod::serialize_aos(@meta).compile_time_value;
+ make Perl6::Pod::serialize_object(
+ 'Pod::FormattingCode',
+ :type($*W.add_string_constant(~$<code>).compile_time_value),
+ :@content,
+ :@meta,
+ ).compile_time_value;
} else {
my @content := [];
for $<pod_string_character> {
View
@@ -593,15 +593,18 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$*POD_ALLOW_FCODES := 0;
}
}
- $<content>=[
- <!before $endtag>
- [ <?{$<code> ne 'L' && $<code> ne 'D' && $<code> ne 'X' }> || <!before \s* \| > ]
- <pod_string_character>
- ]*
+ [ <!{$<code> eq 'E'}>
+ $<content>=[
+ <!before $endtag>
+ [ <?{$<code> ne 'L' && $<code> ne 'D' && $<code> ne 'X' }> || <!before \s* \| > ]
+ <pod_string_character>
+ ]*
+ ]?
[
| <?{$<code> eq 'L'}> \s* \| \s* $<meta>=[<!before $endtag>.]+
- | <?{$<code> eq 'X'}> \s* \| \s* ( [$<meta>=[<!before $endtag | <[,;]> >.]+] +% \, ) +% \;
- | <?{$<code> eq 'D'}> \s* \| \s* [$<meta>=[<!before $endtag | \; >.]+] +% \;
+ | <?{$<code> eq 'X'}> \s* \| \s* ( [$<meta>=[<!before $endtag | <[,;]> >.]+] +%% \, ) +%% \;
+ | <?{$<code> eq 'D'}> \s* \| \s* [$<meta>=[<!before $endtag | \; >.]+] +%% \;
+ | <?{$<code> eq 'E'}> ( <integer> | $<html_ref>=<[a..z]>+ | $<uni_name>=<[A..Z]>+ ) +%% \;
]?
[ $endtag || <.panic: "Pod formatting code $<code> missing endtag '$endtag'."> ]
}
Oops, something went wrong.

0 comments on commit eff1c27

Please sign in to comment.