【发布时间】:2014-02-18 02:56:00
【问题描述】:
我正在尝试使用 FSharp.Literate 来生成 html 页面。我正在使用 Mono 4.5 在 Xamarin 中工作。我想将基本的*.fsx 脚本转换为 html。我正在使用简单的script example from the documentation 进行测试。我想转成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" 解决了问题
【问题讨论】:
标签: html f# mono xamarin literate-programming