【问题标题】:asp.net mvc translate <asp> to razor markdowndeepasp.net mvc 将 <asp> 翻译成 razor markdowndeep
【发布时间】:2015-12-19 21:32:03
【问题描述】:

从事“学校”项目,这是一种堆栈溢出的“重制”。 “翻拍”已经完成,只剩下一个部分。

试图弄清楚如何实现 markdown(deep),以便可以发布问题和答案,内容丰富,而不仅仅是文本。

现在我花了半天时间找到并设法运行了一个示例。

我唯一的问题是,它不适用于我的项目。

这是我使用的来源 MarkdownDeep

所以我在我自己的控制器的给定源中使用完全相同的方式来完成视图:'NewQuestion'

要显示的静态(示例)内容:

static string m_Content =
  @"# Edit this Page with MarkdownDeep
    This demo project shows how to use MarkdownDeep in a typical ASP.NET MVC application.
  * Click the *Edit this Page* link below to make changes to this page with MarkdownDeep's editor
  * Use the links in the top right for more info.
  * Look at the file `MarkdownDeepController.cs` for implementation details.
    MarkdownDeep is written by [Topten Software](http://www.toptensoftware.com).
    The project home for MarkdownDeep is [here]
    http://www.toptensoftware.com/markdowndeep). ";

控制器:

public ActionResult Index()
{
    // View the user editable content
    // Create and setup Markdown translator
    var md = new MarkdownDeep.Markdown();
    md.SafeMode = true;
    md.ExtraMode = true;
    // Transform the content and pass to the view
    ViewData["Content"] = md.Transform(m_Content);
    return View();
}

查看(新问题):

..
<div class="row">
    <div class="col-md-8">
       @ViewData["Content"]
    </div>
</div>
...

结果

如您所见,没有找不到 js 或 jQuery 文件之类的错误。在我看来,内容正确地转换了。

可能是因为示例从&lt;asp&gt; 运行而我使用的是剃须刀?

我真的很困惑,无法弄清楚如何解决问题。已经花了几个小时来了解发生了什么。另外,刚开始在 asp.net 上,所以你真的可以在这里帮助我。

ps,如果需要更多信息/细节,我很乐意更新这篇文章。

【问题讨论】:

    标签: asp.net-mvc markdown markdowndeep


    【解决方案1】:

    尝试使用 Html.Raw()

    @Html.Raw(@ViewData["Content"])
    

    【讨论】:

    • 非常感谢,没想到会这么简单。搜索了几个小时(错误搜索)。非常感谢!
    猜你喜欢
    • 2021-05-04
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多