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

Indented list not correctly converted #19

Closed
gutobenn opened this issue Jan 29, 2015 · 3 comments
Closed

Indented list not correctly converted #19

gutobenn opened this issue Jan 29, 2015 · 3 comments
Labels

Comments

@gutobenn
Copy link

The list

<ul>
    <li>normal list item
        <ul>
            <li>indented item</li>
            <li>another one</li>
        </ul>
    </li>
    <li>normal item again</li>
</ul>

should be converted to:

- normal list item
 - indented item
 - another one
- normal item again

But it is being converted to:

- normal list item- indented item
- another one
- normal item again
@nickcernis nickcernis self-assigned this Mar 4, 2015
@colinodell colinodell added the bug label May 28, 2015
@colinodell
Copy link
Member

It looks like the current version doesn't track the current list level, so this will likely require a partial/full rewrite before we can get it working properly.

tomzx added a commit to TomzxForks/html-to-markdown that referenced this issue Jul 25, 2015
Add an openElement/closeElement to the converters so that they may track additional information once they're about to be converted/have been converted.

This allows us to track the number of ul/ol opened, such that when we render the li element, we know the current indent level.
tomzx added a commit to TomzxForks/html-to-markdown that referenced this issue Jul 25, 2015
Add an openElement/closeElement to the converters so that they may track additional information once they're about to be converted/have been converted.

This allows us to track the number of ul/ol opened, such that when we render the li element, we know the current indent level.
tomzx added a commit to TomzxForks/html-to-markdown that referenced this issue Jul 25, 2015
Add an openElement/closeElement to the converters so that they may track additional information once they're about to be converted/have been converted.

This allows us to track the number of ul/ol opened, such that when we render the li element, we know the current indent level.
@marijnvdwerf
Copy link

Would this change to ListItemConverter solve those issues?

$value = implode("\n", $lines);

if ($list_type === 'ul') {
    $indent = '- ';
} else {
    $number = $element->getSiblingPosition();
    $indent = $number . '. ';
}

$value = trim($value);
$value = preg_replace('~\n~', "\n" . str_repeat(' ', strlen($indent)), $value);

$markdown = $indent . $value . "\n";

@colinodell
Copy link
Member

Fixed by #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants