Compare commits
No commits in common. "99f5d1e660e75197d04be32623744b5443842562" and "1de5e568efd5f9014e6404b1df7858654a685375" have entirely different histories.
99f5d1e660
...
1de5e568ef
@ -1,7 +1,7 @@
|
||||
<phpunit bootstrap="vendor/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="logseq2gemtext">
|
||||
<directory>tests</directory>
|
||||
<testsuite name="parser">
|
||||
<file>tests/ParserTest.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
@ -22,9 +22,6 @@ class ArticleParser extends Parser {
|
||||
$last_node = null; //updated every time
|
||||
$previous_node = null; // we only update this for significant nodes
|
||||
|
||||
$block_level = 0;
|
||||
$list_item = 0;
|
||||
|
||||
$walker = $this->document->walker();
|
||||
while ($event = $walker->next()) {
|
||||
$entering = $event->isEntering();
|
||||
@ -38,16 +35,10 @@ class ArticleParser extends Parser {
|
||||
}
|
||||
|
||||
if (!$entering) {
|
||||
if ($node instanceof ListBlock) {
|
||||
$block_level -= 1;
|
||||
$list_item = 0;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($node instanceof ListBlock) {
|
||||
$block_level += 1;
|
||||
$in_frontmatter = false;
|
||||
continue;
|
||||
}
|
||||
@ -64,15 +55,8 @@ class ArticleParser extends Parser {
|
||||
}
|
||||
}
|
||||
|
||||
if ($block_level > 1) {
|
||||
$list_item += 1;
|
||||
|
||||
$leader = $list_item === 1 ? "\n" : "";
|
||||
$gemtext[] = $leader . '* ' . $text;
|
||||
} else {
|
||||
$leader = $previous_node ? "\n" : "";
|
||||
$gemtext[] = $leader . $text;
|
||||
}
|
||||
|
||||
$previous_node = $node;
|
||||
|
||||
|
@ -95,10 +95,4 @@ class ArticleParserTest extends TestCase {
|
||||
$this->parser->load(vfsStream::url('root/article.md'));
|
||||
$this->assertSame("=> bar foo\n\n=> foo bar", $this->parser->convert());
|
||||
}
|
||||
|
||||
public function testList() {
|
||||
$this->setArticleText("- para\n\t- item 1\n\t- item 2\n- out");
|
||||
$this->parser->load(vfsStream::url('root/article.md'));
|
||||
$this->assertSame("para\n\n* item 1\n* item 2\n\nout", $this->parser->convert());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user