Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何保存c++;html中的模板代码? 我在HTML/CSS/JavaScript中为我的公司编写C++风格指南。我对html非常恼火,因为它将之间的任何内容都视为html标记,并因此处理它们。因此,我的代码(我放在样式指南中)看起来不是这样的。以下是一个例子: <pre> std::vector<std::string> get_project_names(); template<typename Printable> void print(Printable const & item); template<typename FwdIterable, typename Predicate> FwdIterable find_if(FwdIterable begin, FwdIterable end, Predicate pred); </pre> string.replace('<','&lt;').replace('>','&gt;'); std::vector get_project_names(); 模板 无效打印(可打印常量和项目); 模板 FwdIterable find_if(FwdIterable begin,FwdIterable end,谓词pred);_Javascript_Html_Css - Fatal编程技术网

如何保存c++;html中的模板代码? 我在HTML/CSS/JavaScript中为我的公司编写C++风格指南。我对html非常恼火,因为它将之间的任何内容都视为html标记,并因此处理它们。因此,我的代码(我放在样式指南中)看起来不是这样的。以下是一个例子: <pre> std::vector<std::string> get_project_names(); template<typename Printable> void print(Printable const & item); template<typename FwdIterable, typename Predicate> FwdIterable find_if(FwdIterable begin, FwdIterable end, Predicate pred); </pre> string.replace('<','&lt;').replace('>','&gt;'); std::vector get_project_names(); 模板 无效打印(可打印常量和项目); 模板 FwdIterable find_if(FwdIterable begin,FwdIterable end,谓词pred);

如何保存c++;html中的模板代码? 我在HTML/CSS/JavaScript中为我的公司编写C++风格指南。我对html非常恼火,因为它将之间的任何内容都视为html标记,并因此处理它们。因此,我的代码(我放在样式指南中)看起来不是这样的。以下是一个例子: <pre> std::vector<std::string> get_project_names(); template<typename Printable> void print(Printable const & item); template<typename FwdIterable, typename Predicate> FwdIterable find_if(FwdIterable begin, FwdIterable end, Predicate pred); </pre> string.replace('<','&lt;').replace('>','&gt;'); std::vector get_project_names(); 模板 无效打印(可打印常量和项目); 模板 FwdIterable find_if(FwdIterable begin,FwdIterable end,谓词pred);,javascript,html,css,Javascript,Html,Css,我希望浏览器呈现出与此完全相同的效果,但它不是这样呈现的,例如Chrome不显示部分,IE 8.0将大写为(以及所有此类模板代码) 我不想受到html引擎的任何干扰。有什么简单的方法可以实现我想要的吗?有没有礼貌的方式告诉浏览器不要修改我的代码 请注意,将

我希望浏览器呈现出与此完全相同的效果,但它不是这样呈现的,例如Chrome不显示
部分,IE 8.0将
大写为
(以及所有此类模板代码)

我不想受到html引擎的任何干扰。有什么简单的方法可以实现我想要的吗?有没有礼貌的方式告诉浏览器不要修改我的代码

请注意,将
替换为
都可以,但每次编写模板代码时都很麻烦。这也使得我的代码很难在html的源代码中阅读。因此,我正在寻找一个简单的解决方案。

XML的CDATA功能正是“礼貌地告诉浏览器不要修改(解析)我的代码”。不多不少

CDATA在HTML中不存在,因此在HTML中除了(不存在的)
std:vector
元素的开始标记之外,没有其他方法可以将
视为其他内容

通常的方法是服务器端转换。现在,如果您不是生成HTML服务器端,而是手工编写,那么通过这样的客户端转换,您的生活就变得简单了:

<!DOCTYPE html>
<html>
<title>JavaScript API</title>

<xmp theme="united" style="display:none;">

## Print the name

Print the user's name:

```javascript
function printName(name) {
    alert(name);
}
```
</xmp>

<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script>
</html>

页面标题
document.write“
std::vector get_project_names();

“.replace(”我多年来一直在处理这个特殊的问题,它总是令人沮丧。我一直很欣赏Markdown的简单和优雅,所以我做了一些研究,看看是否有任何方法可以使用Markdown来构建HTML文档

事实是,代码示例有时涉及HTML,但HTML是我们用来编写样式指南和API文档的语言,所以我的想法是,如果我们用Markdown编写API文档和样式指南,我们将消除HTML和其他语言语法之间的所有冲突

我发现,这是一个库,它允许您使用纯标记创建网页。然后,该库将其编译为HTML并在页面客户端呈现。我们使用该库为我们的一款产品整合API文档,并将其发布为GitHub页面

下面是一个简单的小例子:

var string = "content here";

应用程序编程接口
##打印姓名
打印用户名:
```javascript
函数printName(名称){
警报(名称);
}
```
标记中的所有内容都被编译为HTML



<强>注:

string.replace(“”,”);
转换所有字符,然后由浏览器渲染

在我的书中,我使用了语法高亮。将代码粘贴到其中,生成高亮显示的代码,然后将后者粘贴到HTML文档中。效果非常好。下面是对代码的修改:

以下是突出显示的HTML代码:

std::vectorst::string>get_project_names();
templatetypename可打印>
无效打印(可打印常量和项目);
templatetypename可编辑,typename谓词>
FwdIterable find_if(FwdIterable begin,FwdIterable end,谓词pred);

你只是在寻找
吗?@Anonymous:这个假定的副本并没有回答我的问题,因为它说“但这只在XML中有效(因此XHTML,但不是所有浏览器都支持它),而不是在HTML中。”@Nawaz在同一个答案下面看一下。对于建议的副本似乎有很多好的建议。我认为你是手工编写HTML,而不是使用预处理器来转换HTML。对吗?@Nawaz如果你愿意,你可以使用一些工具来加速这个过程,但这就是答案。试着看看St例如,ack Overflow的源代码。听起来询问者是在手工编写代码。每次将其包装成字符串可能与转换
一样麻烦
var string = "content here";
string.replace('<','&lt;').replace('>','&gt;');
<pre style="background:#000;color:#f8f8f8">std::vector&lt;std::string>  <span style="color:#89bdff">get_project_names</span>();    

<span style="color:#99cf50">template</span>&lt;<span style="color:#99cf50">typename</span> Printable> 
<span style="color:#99cf50">void</span> <span style="color:#89bdff">print</span>(Printable const &amp; item);    

<span style="color:#99cf50">template</span>&lt;<span style="color:#99cf50">typename</span> FwdIterable, <span style="color:#99cf50">typename</span> Predicate> 
FwdIterable <span style="color:#89bdff">find_if</span>(FwdIterable begin, FwdIterable end, Predicate pred);
</pre>