我正在尝试使用 FSharp.Literate 来生成 html 页面。我正在使用 Mono 4.5 在 Xamarin 中工作。我想将基本*.fsx
脚本转换为 html。我正在使用文档中的简单脚本示例进行测试。我希望变成 html 的脚本如下所示。
(**
# First-level heading
Some more documentation using `Markdown`.
*)
(*** include: final-sample ***)
(**
## Second-level heading
With some more documentation
*)
(*** define: final-sample ***)
let helloWorld() = printfn "Hello world!"
我使用内置的 NuGet 管理器下载FSharp.Formatting
. 它还安装Microsoft.AspNet.Razor 2
并RazorEngine
根据文档中的示例,我编写了以下脚本,将上面的示例转换为 html。我正在使用来自 github 上原始 FSharp.Formatting 的 html 模板。
#I "bin/Debug/"
#r "FSharp.Literate.dll"
#r "FSharp.Markdown.dll"
#r "FSharp.CodeFormat.dll"
open System.IO
open FSharp.Literate
let source = __SOURCE_DIRECTORY__
let baseDir = Path.Combine(source, "html/")
let file = Path.Combine(baseDir, "demo.fsx")
let output = Path.Combine(baseDir, "demo-script.html")
let template = Path.Combine(baseDir, "template.html")
Literate.ProcessScriptFile(file, template, output)
该过程运行并生成一个 html 文件。但是,F# 代码不会标记化。我得到了下面的示例,而不是格式良好的代码。我错过了一些明显的东西吗?
编辑:
根据下面 Tomas 的评论,我发现 .css 和 .js 文件存在问题。我使用的模板有href="{root}/content/style.css" /> <script src="{root}/content/tips.js"
{root} 标签是它找不到 css 和 js 文件的原因。改变它以href="content/style.css" /> <script src="content/tips.js"
解决问题