Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Asciidoc unindented lists #149

Merged
merged 1 commit into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/Locale/Po4a/AsciiDoc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ sub parse {
$self->pushline(".$t\n");
@comments=();
} elsif (not defined $self->{verbatim} and
($line =~ m/^(\s*)((?:[-*o+]|(?:[0-9]+[.\)])|(?:[a-z][.\)])|\([0-9]+\)|\.|\.\.)\s+)(.*)$/)) {
($line =~ m/^(\s*)((?:[-*o+]+|(?:[0-9]+[.\)])|(?:[a-z][.\)])|\([0-9]+\)|\.|\.\.)\s+)(.*)$/)) {
my $indent = $1||"";
my $bullet = $2;
my $text = $3;
Expand Down Expand Up @@ -645,6 +645,18 @@ sub parse {
do_paragraph($self,$paragraph,$wrapped_mode);
$paragraph="";
$wrapped_mode = 1;
}
elsif ($paragraph ne "" && $self->{bullet} && length($self->{indent}||"")==0 &&
($line =~ m/^(\s*)((?:[-*o+]+|([0-9]+[.\)])|\([0-9]+\))\s+)/s)) {
# If the next line starts with a bullet, process this immediately and setup the next line
print STDERR "IM HERE\n";
do_paragraph($self,$paragraph,$wrapped_mode);
$paragraph="";
$wrapped_mode = 0;
$self->unshiftline($line,$ref);
$line="";
undef $self->{bullet};
undef $self->{indent};
} else {
# A stupid paragraph of text
print STDERR "Regular line. ".
Expand All @@ -659,10 +671,11 @@ sub parse {
}

if ($paragraph ne "" && $self->{bullet} && length($self->{indent}||"")==0) {
# Second line of an item block is not indented. It looks like a broken indentation
# I'd prefer not to accept it, but the formaters do. Damn specification
# Second line of an item block is not indented. It is unindented
# (and allowed) additional text or a new list item.
print STDERR "$ref: It seems that you are adding unindented content to an item.\n".
"The \"standard\" allows this, but you may still want to fix your document.\n";
"The standard allows this, but you may still want to change your document\n".
"to use indented text to provide better visual clues to writers.\n";
} else {
undef $self->{bullet};
undef $self->{indent};
Expand Down
7 changes: 7 additions & 0 deletions t/t-03-asciidoc/Lists.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ a. Lowercase letter numbered list item with optional numbering.
3. Donec eget arcu bibendum nunc consequat lobortis.
4. Nam fermentum mattis ante.

* List Item 1
** Non-indented new list Item
** Another Item
* List Item 2
* List Item 3
** Non-indented new list Item 2

Vertical Labeled Lists
----------------------

Expand Down
3 changes: 2 additions & 1 deletion t/t-03-asciidoc/Lists.err
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
t-03-asciidoc/Lists.asciidoc:9: It seems that you are adding unindented content to an item.
The "standard" allows this, but you may still want to fix your document.
The standard allows this, but you may still want to change your document
to use indented text to provide better visual clues to writers.
7 changes: 7 additions & 0 deletions t/t-03-asciidoc/Lists.out
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ a. Lowercase letter numbered list item with optional numbering.
3. Donec eget arcu bibendum nunc consequat lobortis.
4. Nam fermentum mattis ante.

* List Item 1
** Non-indented new list Item
** Another Item
* List Item 2
* List Item 3
** Non-indented new list Item 2

Vertical Labeled Lists
----------------------

Expand Down
Loading