如何用HTML语言编写降价语言

如何用HTML语言编写降价语言

本文介绍了如何用HTML语言编写降价语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

md文件中的

#(以及 ## ### )具有标题1(2,3)的含义./p>

此md(markdown)标头供我开发的内容小部件表使用.

我想使用在ejs(模板引擎)html布局文件中定义的md标头(写为#).如何用ejs(html)语言编写#,以便TOC小部件也使用与markdown md文件中的#相同的方式?

更清楚的是:

以markdown md文件语言编写的#与以ejs(html)语言编写的<%= header%> 相同吗?我正在寻找如何用EJS(html)语言编写#的方法.例如,可能是这样的事情(我不知道,只是为了说明我的问题):降价语言中的#等于<%=标头%> 在ejs中(html)?????

显然,我的问题仍然不清楚.很简单:如何用ejs(html)语言编写#(markdown语言),以便以与#相同的方式解析ejs(html)文件中的代码在降价?

解决方案

您可以使用标记包为了那个原因.示例:

  $(document).ready(function(){var content = $('.my-md').html();$('.my-md').html(已标记(内容));});  
 < script src ="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js></script>< script src ="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>< div class ="container">< div class ="my-md"># 你好,世界这是一个简单的测试.</div></div> 

# (and ## and ###) in md files has the meaning of header 1 (2, 3).

This md (markdown) header is used by a table of content widget I developed.

I want to use a md header (written as #) that is defined in ejs (template engine) html layout file.How to write # in ejs (html) language so that it is also used by TOC widget same way as # in markdown md file?

To be more clear:

The # in markdown md file language is the same as <%= header %> when written in ejs (html) language? I am looking how to write # in EJS (html) language.For example, it could be something like this maybe (I do not know, but just to illustrate my question): # in markdown language equals <%= header %> in ejs (html) ?????

Apparently, my question is still not clear.It is simple: How to write # (markdown language) in ejs (html) language so that the code from the ejs (html) file is parsed the same way as # in markdown?It

解决方案

You can use marked package for that. Example:

$(document).ready(function(){
  var content = $('.my-md').html();
  $('.my-md').html(marked(content));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="container">
 <div class="my-md">
# Hello world
This is ** a simple test ** .
  </div>
</div>
 

这篇关于如何用HTML语言编写降价语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 02:03