English 中文(简体)
如何用 BASH 取代 HTML
原标题:How to replace HTML with BASH

我要在我的服务器上运行一个bash 脚本, 并在网页上显示输出。 脚本启动 trough php, 并且正在工作 。 - 但我重写喜欢将特定关键字颜色化 。 如何做最好?

<强 > 可能的解决办法:

我能找到关键词( 警告) 的起始点, 使用 < code> string. search (" 警告" ) ; (我不知道如何找到结尾) 。 - 并用 < code> string. substring (from, to) 来选择关键词。 然后使用 < code> string.fontcolor ("red") 来显示颜色, 以及 < code > document. write( 颜色string); 来显示它 。

<强>编辑:

“强者”我不认为我的问题已经明确了,所以我再试一次:“/强”

php 运行bash 脚本, 返回文字, 例如 。

"This is some text that bash returns"

我如何最好地把案文变成

"This is <span class= keyword >some</span> text that bash returns"

这样我就可以对关键字(“ 某些” ) 应用彩色样式吗?

最佳回答

如果您只想要在给定字符串中进行折行, 然后是样式, 特定的字符串 :

var str = "This is some text that bash returns",
    styledString = str.replace(/some/gi, <span class="keyword">some</span> );

JS 概念的简单证明

问题回答

您的最佳赌注是使用 和 CSS 类,而不是内嵌样式。 区分样式和数据对于维护网站很重要 。

<span class= keyword >warning</span>

CSS :

.keyword {
   font-color:#ff0000;
   font-weight:bold;
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签