From adb6e326d217635cf9de8a316b6331954914a45d Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Sun, 11 May 2025 15:55:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=85=E4=BA=8B=E7=BA=BF?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=83=85=E5=86=B5=E4=B8=8B=E5=B4=A9=E6=BA=83?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AstConv/HtmlStruct.fs | 42 +++++++++++++++++--------- AstConv/Properties/launchSettings.json | 2 +- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/AstConv/HtmlStruct.fs b/AstConv/HtmlStruct.fs index f3c2a02..3b7fe59 100644 --- a/AstConv/HtmlStruct.fs +++ b/AstConv/HtmlStruct.fs @@ -980,7 +980,7 @@ open System.IO $"{a.Value.name()}&{b.name()}", b.address()) // 故事线之间的节点连线 - let towards_arrs = fragment_defs|> List.map(fun (_, defn) -> + let towards_prim = fragment_defs|> List.map(fun (_, defn) -> let node_refs = defn.children() |> List.filter(fun v -> v:? AstImport.FragmentRef) |> List.map(fun v -> v:?> AstImport.FragmentRef) @@ -992,10 +992,14 @@ open System.IO ) ) |> List.reduce(fun al bl-> al @ bl) - |> List.reduce(fun a b -> a + b) - let all_arrows = arrows_decl + towards_arrs - + let all_arrows = + if towards_prim.IsEmpty then + arrows_decl + else + let towards_arrs = towards_prim |> List.reduce(fun a b -> a + b) + arrows_decl + towards_arrs + $"""digraph node_relates{{ rankdir=LR label="{gname}" @@ -1087,17 +1091,25 @@ open System.IO |> List.map(fun v -> v, (v.children()|> List.filter(fun v-> v:? AstImport.FragmentRef))) // 获取文章节点和他的引用线 |> List.filter(fun (_, al)-> al.Length > 0) - let refers = rst|> List.map(fun (a, refsa) -> - refsa|> List.map(fun refn -> - let refx = refn :?> AstImport.FragmentRef - let target_name = $"""{refx.storyRef()}&{refx.sliceRef()}""" - let _, target_address = node_map|> List.filter(fun (a, _) -> a = target_name)|> List.item 0 - $"""node_{a.address()}--node_{target_address} - """ - ) - ) - |> List.reduce (fun a b -> a @ b) - |> List.reduce (fun a b -> a + b) + let refers_prim= + if not rst.IsEmpty then + rst |> List.map(fun (a, refsa) -> + refsa |> List.map(fun refn -> + let refx = refn :?> AstImport.FragmentRef + let target_name = $"""{refx.storyRef()}&{refx.sliceRef()}""" + let _, target_address = node_map|> List.filter(fun (a, _) -> a = target_name)|> List.item 0 + $"""node_{a.address()}--node_{target_address} + """ + ) + ) + |> List.reduce (fun a b -> a @ b) + else [] + + let refers = + if refers_prim.IsEmpty then + "" + else + refers_prim |> List.reduce (fun a b -> a + b) $"""graph{{ label="{gname}" {clusters_desc} {refers} }}""" diff --git a/AstConv/Properties/launchSettings.json b/AstConv/Properties/launchSettings.json index deb1f45..4541d53 100644 --- a/AstConv/Properties/launchSettings.json +++ b/AstConv/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "AstConv": { "commandName": "Project", - "commandLineArgs": "--file \"E:/storyline.xast\" --format" + "commandLineArgs": "--file \"E:/storyline.xast\" --html \"E:/html\"" } } } \ No newline at end of file