小编Bal*_*uin的帖子

mkdocs 中带有 markdown_include.include 的相对链接(到标题)

我不确定是否有可能解决这个问题 - 但无论如何我会问:

\n

我正在开发一个 python 项目,使用 mkdocs 作为文档。
\n项目结构(简化)大致如下:

\n
./\n|-- docs\n    |-- index.md\n    |-- page2.md\n    \xe2\x94\x94-- [other documentation stuff]\n|-- [the actual program stuff]\n|-- README.md\n\xe2\x94\x94-- mkdocs.yml\n
Run Code Online (Sandbox Code Playgroud)\n

我正在使用 markdown_extensions markdown_include.include(在 mkdocs.yml 中声明),\n并且 index.md 仅包含{!README.md!}在此位置包含 markdown 文件的行。

\n

这很好用,将 README.md 显示为文档的概述页面。

\n

我现在遇到的问题是,在 README.md 中,我想有一个声明“有关更多详细信息,请参阅 XY”,其中 XY 应该是指向page2.md文档中标题的链接。

\n

使用 mkdocs,我可以简单地编写see [here](page2.md#heading2),并且在文档中完美运行。但是当我直接查看 README.md(例如在 github 上)时,结果是 404。

\n

当我放置 时see [here](docs/page2.md/#heading2),它在 README.md 中起作用,但在 mkdocs 创建的文档中不起作用。

\n

有什么好的方法可以解决这个问题吗?非常感谢您的帮助!

\n

mkdocs

7
推荐指数
0
解决办法
3771
查看次数

RDFLib 中的命名空间绑定

在以下最小测试用例中:

from rdflib import Graph, Namespace, Literal, RDF

base = "http://test.com/ns"
foobar = Namespace("http://test.com/ns#")
g = Graph(base=base)
g.bind('foobar', foobar)

g.add((foobar.something, RDF.type, Literal('Blah')))
g.add((foobar.something, foobar.contains, Literal('a property')))

g.add((foobar.anotherthing, RDF.type, Literal('Blubb')))
g.add((foobar.anotherthing, foobar.contains, Literal('another property')))

print(g.serialize(format='turtle').decode("utf-8"))
Run Code Online (Sandbox Code Playgroud)

我明白了

@base <http://test.com/ns> .
@prefix foobar: <http://test.com/ns#> .

<#anotherthing> a "Blubb" ;
    ns1:contains "another property" .

ns1:something a "Blah" ;
    ns1:contains "a property" .
Run Code Online (Sandbox Code Playgroud)

我期望的更像是

@base <http://test.com/ns> .
@prefix foobar: <http://test.com/ns#> .

<#anotherthing> a "Blubb" ;
    foobar:contains "another property" .

<#something> a "Blah" ;
    foobar:contains "a …
Run Code Online (Sandbox Code Playgroud)

python rdf rdflib turtle-rdf

6
推荐指数
1
解决办法
1559
查看次数

标签 统计

mkdocs ×1

python ×1

rdf ×1

rdflib ×1

turtle-rdf ×1