gh|500

Sometimes, you need to copy data generated by Dataview for reuse. The Dataview Serializer plugin comes in handy for this purpose.

Obs130 - Technique for Generating Dataview Tables into Markdown Format and Copying to Clipboard using Dataviewjs introduced a method using Dataviewjs with JavaScript to add a 'Copy' button below the table. This generates the query content in Markdown format and copies it to the clipboard. While this method retrieves Markdown content, writing the script can be somewhat cumbersome.

Today, we introduce two plugins for retrieving Dataview tables: Dataview Serializer and Enhanced Copy.

Dataview Serializer can generate Markdown content from Dataview output (tables or lists). Copying this Markdown content allows for easy reuse.

The other plugin, Enhanced Copy, can replace Obsidian's built-in copy function (Ctrl+C). By enabling the option in its settings to copy Dataview and Dataviewjs content, you can copy Dataview tables in Markdown format to the clipboard when executing the 'Copy selected text' command.

In terms of ease of use, Enhanced Copy is more convenient.

1. Enhanced Copy Plugin

1.1. Example

Use Dataviewjs to list all Obsidian commands, then use Enhanced Copy to quickly get the Markdown content.
Press Ctrl+Shift+C to copy.

name List All Obsidian Commands
type link
action obsidian://advanced-uri?vault=jerry-notes&filepath=000-Index/!list all commands
color purple

Reference: Obs127 - Simplifying Obsidian Automation Scripts with Templater Hotkeys

2. Dataview Serializer Plugin

2.1. Syntax

  • Write the Dataview query you want to serialize between <!-- QueryToSerialize: and -->.
  • Note: There <mark style="background-color:#bf616a">must be no line breaks</mark> within the Dataview statement.
Syntax

<!-- QueryToSerialize: DATAVIEW STATEMENT -->

The plugin scans notes in the specified folders. When it finds a QueryToSerialize comment block, it automatically generates the following content:

  • <!-- SerializedQuery: DATAVIEW STATEMENT -->
  • The Markdown content of the Dataview result
  • <!-- SerializedQuery END -->

2.2. Settings

  • In the plugin options, you can configure the folders to scan. Only notes within these specified folders will have their QueryToSerialize comment blocks parsed.
  • You can also configure folders to exclude from scanning in the plugin options.
  • You can run the Scan and serialize all Dataview queries command to scan Dataview queries.

2.3. Example

  • Switch to Source mode to view the serialized Markdown content.
Note type Created Modified
[[AHK64|用AutoHotkey V2產生Yanki MD檔,快速建立Anki閃卡]] 專案筆記 2024-08-09 2024-08-10
[[Anki-05-Autohotkey-generates-flashcards]] 專案筆記 2022-03-26 2023-04-26
[[Anki-06-yomichan]] 專案筆記 2022-03-26 2023-08-15
[[Anki-03-單詞寶:快速新增英文字卡的Addon之一]] 專案筆記 2022-03-26 2023-12-14
[[Saladict 與Anki整合]] 專案筆記 2022-03-26 2023-08-30

▼ Dataview Table

table without ID file.link as Note, type, substring(created,0,10) as Created, 
  substring(modified ,0,10) as Modified from #anki where type="專案筆記"
limit 5 sort file.name

💡 Explanatory Article: https://jdev.tw/blog/8510/
✅ Enhanced Copy: https://github.com/Mara-Li/obsidian-enhanced-copy
✅ Dataview Serializer: https://github.com/dsebastien/obsidian-dataview-serializer
✅ Official Documentation Obsidian Dataview Serializer: https://developassion.gitbook.io/obsidian-dataview-serializer
✅ List All Commands Obs127 - Simplifying Obsidian Automation Scripts with Templater Hotkeys: https://youtu.be/U8HDmoQAwts

4. Tutorial Video