')
->toContain('第一点')
->toContain('
另起一段');
});
it('renders notes as markdown footnotes', function () {
$markdown = app(MarkupService::class)->renderMany(
[['source' => 'first'.($set = new AnnotationSet)->note('注释正文').' sentence', 'annotations' => $set]],
new RenderOptions(format: Format::Markdown, footnote: true),
)[0];
expect($markdown)->toBe("first[^1] sentence\n\n[^1]: 注释正文");
});
it('parses the note body in its own dialect', function () {
$tree = annotated('句子', [], Format::Tree, fn (AnnotationSet $set) => [
['id' => 'n1', 'at' => 2, 'order' => [0, 0, 0], 'html' => $set->note('用 `code`', [], 'markdown-e2')],
]);
expect($tree[1]['children'][1])->toMatchArray(['type' => 'el', 'tag' => 'code']);
});
it('gives sidenotes page-unique ids from the item id prefix', function () {
$html = app(MarkupService::class)->renderMany([
['source' => 'a{{n|x}}', 'idPrefix' => '65-1-2-3'],
['source' => 'b{{n|y}}', 'idPrefix' => '65-1-4-5'],
], new RenderOptions(format: Format::Html));
expect($html[0])->toContain('id="sn-65-1-2-3-1"')->and($html[1])->toContain('id="sn-65-1-4-5-1"');
});
it('ignores annotation tokens and internal template names written in content', function () {
$stray = '正文'.AnnotationToken::make(0).'{{anno-issue|ids=x}}';
$tree = json_decode(json_encode(app(MarkupService::class)->render($stray, new RenderOptions)), true);
expect($tree[0])->toBe(['type' => 'text', 'value' => '正文']);
expect($tree[1])->toMatchArray(['name' => 'unknown']);
});