I exported a notebook to markdown (which is great), but I found that the files don't have links to other files like they were in Siyuan.
So, is there anyway to make markdown exports have links to other files?
I exported a notebook to markdown (which is great), but I found that the files don't have links to other files like they were in Siyuan.
So, is there anyway to make markdown exports have links to other files?
I think there is a fairly simple solution to this, which I will describe below. I think it can be implemented as a simple Python script that does some post-processing of the exported markdown files. I will try to create a proof-of-concept script, but it will take me a few days because I am not a programmer and will need to learn some Python programming first.
In Settings > Export configure 'Ref' to 'Anchor text with block URL'. After doing this, a link to another block in a SiYuan note appears in the exported Markdown file as [Anchor text](siyuan://blocks/block-id)
.
Write a Python script that opens each exported markdown file and uses regex matching to identify all instances of [Anchor text](siyuan://blocks/block-id)
. For each instance,
Use the /api/query/sql
API endpoint to get details of the block-id
by making a query like:
{ "stmt": "SELECT * FROM blocks WHERE id='block-id'" }
In the query result, you can find the hpath
key whose value is a human readable path.
siyuan://blocks/block-id
with hpath_value.md which would be the relative path to the exported markdown file that the link points to.hpath
for that block-id), find the start of the paragraph and add an <a name="block-id"></a>
anchor at the start of the paragraph. Then, the siyuan://blocks/block-id
in the exported markdown file can be replaced by hpath_value.md#block-id
This would basically solve the problem of having correct links in the exported markdown files and additionally the exported notes can easily be converted to HTML and published e.g. with a static site generator like Hugo.
@88250 Do you see any problems with this approach? I don't understand why SiYuan does not do this already when exporting to markdown.. but in any case, a Python script that does the above can post-process the exported markdown files from SiYuan and fix all the links. What do you think?
In theory, programs that support standard Markdown (CommonMark) should be able to support parsing and rendering inline HTML elements, that is, <span>
, but they may not necessarily support anchor hash jumps. After rendering from Markdown to HTML, the browser can support anchor hash jumping, so currently, exporting references as anchor hashs is the optimal solution.
The anchor hash
feature currently creates a span object <span id="20231110120736-ze6m41f"></span>
. Some kind of program should be able to understand and find this block inside the note as reference. Can anyone help me understand how this can be useful after export, where do I use this, which program understands this syntax?
The export mode Anchor hash
for notebook Markdown exporting has some limitations.
In the case i want to publish a particular note (with links to other notes) my approach is:
Other limitation of Anchor has
export and the only way I got it to work (performed testing by exporting to Obsidian):
Depending on the responses here I might add a feature request soon that involves the concept of user selectable export syntax. In which before execution of export using anchor hash
a user can type in the conversion syntax to apply. User is presented with input fields much like the settings > Export > Anchor text wrapping symbol
fields.
Conversion syntax for siyuan > obsidian would be: [[test3.md/Note 2#^d8bf62|Note 2]] and conversion input fields could somehow be [[ .. / .. #^ .. | .. ]]
I appreciate your resonse, but it is not only for complete batch export for users to turn away from siyuan, but rather for collaborative reasons and to publish notes. Users of Siyuan can collaborate and share specific notes.
I just want a guide on how to use anchor hash
. How would I proceed after I used the feature after export, so post anchor hash
. I do not quite understand what to do with the new file after export.
Welcome to here!
Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.
Signup About