fix: align local markdown conflict and title behavior
This commit is contained in:
@@ -2780,7 +2780,10 @@ pub fn resolve_local_markdown_page_aggregate(
|
||||
.and_then(page_options_hide_title_header_value)
|
||||
.is_none()
|
||||
{
|
||||
page_options.hide_title_header = true;
|
||||
// 我的空间(有 workspace.json 的托管工作区,包括用户本人的及分享的)默认显示页头标题。
|
||||
// 普通本地文件夹(无托管清单)默认隐藏页头标题,避免文件名与正文 H1 重复。
|
||||
let is_managed = load_local_workspace_manifest(&canonical_root).is_ok();
|
||||
page_options.hide_title_header = !is_managed;
|
||||
}
|
||||
let character_count = parsed.body.chars().count() as u64;
|
||||
let word_count = parsed
|
||||
@@ -10344,6 +10347,23 @@ fn main() {}
|
||||
let aggregate = resolve_local_markdown_page_aggregate(&root_uri, "local-md:File~20Name.md")
|
||||
.expect("aggregate");
|
||||
assert_eq!(aggregate.title, "File Name");
|
||||
// init_workspace 创建的是托管工作区(我的空间),默认显示页头标题。
|
||||
assert!(!aggregate.layout.page_options.hide_title_header);
|
||||
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_markdown_non_managed_folder_default_hides_title_header() {
|
||||
// 非托管本地文件夹:没有 .mnote/workspace.json,应该默认隐藏标题。
|
||||
let root = temp_root("mnote-local-non-managed-title-default");
|
||||
let _ = std::fs::create_dir_all(root.join(".mnote"));
|
||||
std::fs::write(root.join("Page.md"), "# Page Heading\n").expect("write md");
|
||||
let root_uri = format!("file://{}", root.display());
|
||||
|
||||
let aggregate = resolve_local_markdown_page_aggregate(&root_uri, "local-md:Page.md")
|
||||
.expect("aggregate");
|
||||
assert_eq!(aggregate.title, "Page");
|
||||
assert!(aggregate.layout.page_options.hide_title_header);
|
||||
|
||||
let _ = std::fs::remove_dir_all(&root);
|
||||
|
||||
Reference in New Issue
Block a user