本机HTML分组href链接,以实现最佳维护

本机HTML分组href链接,以实现最佳维护,html,Html,我最近开始做降价文档,它有一个非常有用的特性,允许您将所有链接分组在一个地方,并通过调用引用来重用它们。这大大方便了文档的维护 例如,在markdown中,可重用链接的代码如下所示: [Abbreviations]: http://pythonhosted.org/Markdown/extensions/abbreviations.html [Attribute Lists]: http://pythonhosted.org/Markdown/extensions/attr_list.html

我最近开始做降价文档,它有一个非常有用的特性,允许您将所有链接分组在一个地方,并通过调用引用来重用它们。这大大方便了文档的维护

例如,在markdown中,可重用链接的代码如下所示:

[Abbreviations]: http://pythonhosted.org/Markdown/extensions/abbreviations.html
[Attribute Lists]: http://pythonhosted.org/Markdown/extensions/attr_list.html
[Definition Lists]: http://pythonhosted.org/Markdown/extensions/definition_lists.html
[Fenced Code Blocks]: http://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html
[Footnotes]: http://pythonhosted.org/Markdown/extensions/footnotes.html
[Tables]: http://pythonhosted.org/Markdown/extensions/tables.html
[Smart Strong]: http://pythonhosted.org/Markdown/extensions/smart_strong.html
只需调用您的引用名称,即可在文档中的任何位置使用这些链接,例如:

* `abbr` -- [Abbreviations][]
* `attr_list` -- [Attribute Lists][]
* `def_list` -- [Definition Lists][]
* `fenced_code` -- [Fenced Code Blocks][]
* `footnotes` -- [Footnotes][]
* `tables` -- [Tables][]
* `smart_strong` -- [Smart Strong][]
我已经搜索了很多,但我没有发现任何仅使用本机HTML的类似功能

有人有什么想法吗?

从技术上讲,这可以通过javascript在运行时实现——不过为了超文本文档的完整性,我不建议在生产环境中使用:

//设置引用对象
变量引用={
缩写:{
正文:“缩写”,
超链接:'http://pythonhosted.org/Markdown/extensions/abbreviations.html'
},
脚注:{
正文:“脚注”,
超链接:'http://pythonhosted.org/Markdown/extensions/footnotes.html'
},
表:{
文本:“表格”,
超链接:'http://pythonhosted.org/Markdown/extensions/tables.html'
}
}
//循环遍历引用对象
Object.keys(引用).forEach(函数(引用){
var text=references[reference].text;
var hyperlink=references[reference].hyperlink;
var referenceSet=[…document.getElementsByClassName(reference)];
referenceSet.forEach(函数(referenceAnchor){
referenceAnchor.setAttribute('href',超链接);
referenceAnchor.textContent=文本;
});
});
从技术上讲,这可以通过javascript在运行时实现——不过为了超文本文档的完整性,我不建议在生产环境中使用:

//设置引用对象
变量引用={
缩写:{
正文:“缩写”,
超链接:'http://pythonhosted.org/Markdown/extensions/abbreviations.html'
},
脚注:{
正文:“脚注”,
超链接:'http://pythonhosted.org/Markdown/extensions/footnotes.html'
},
表:{
文本:“表格”,
超链接:'http://pythonhosted.org/Markdown/extensions/tables.html'
}
}
//循环遍历引用对象
Object.keys(引用).forEach(函数(引用){
var text=references[reference].text;
var hyperlink=references[reference].hyperlink;
var referenceSet=[…document.getElementsByClassName(reference)];
referenceSet.forEach(函数(referenceAnchor){
referenceAnchor.setAttribute('href',超链接);
referenceAnchor.textContent=文本;
});
});

这是模板语言存在的(许多)原因之一:)嗨!JoséLuis你能告诉我你基于模板的解决方案的细节吗。。。我不知道这是模板语言存在的原因之一:)嗨!JoséLuis你能告诉我你基于模板的解决方案的细节吗。。。我不知道鲁宁是个好办法。。。但是使用JavaScript。。。我正在寻找一个只包含HTML/CSS(用于安全限制)的解决方案。我相当确定,如果不使用javascript,您将无法将
href
属性插入锚元素中。。。。我很害怕。。。但是希望永远不会失去:-)但是。。。我希望有人会知道一些新的东西(HTML5,CSS)或一些旧的trickRounin是一个很好的解决方案。。。但是使用JavaScript。。。我正在寻找一个只包含HTML/CSS(用于安全限制)的解决方案。我相当确定,如果不使用javascript,您将无法将
href
属性插入锚元素中。。。。我很害怕。。。但是希望永远不会失去:-)但是。。。我希望有人会知道一些新的东西(HTML5,CSS)或一些老把戏