zazuko / vscode-sparql-notebook

Visual Studio Code SPARQL Notebook Extension
https://marketplace.visualstudio.com/items?itemName=Zazuko.sparql-notebook
Other
26 stars 8 forks source link

Save as markdown #6

Closed kvistgaard closed 2 years ago

kvistgaard commented 2 years ago

It would be very useful to be able to save a notebook as pure MD for sharing.

The cell should be saved as ```sparql code blocks:

BenjaminHofstetter commented 2 years ago

SPARQL notebooks are serialised to a very simple array of cells with a value and a cell type e.g.

[
    {
        "kind": 1,
        "language": "markdown",
        "value": "# Test Notebook\n\n"
    },
    {
        "kind": 2,
        "language": "sparql",
        "value": "PREFIX wd: <http://www.wikidata.org/entity/>\nPREFIX wdt: <http://www.wikidata.org/prop/direct/>\nPREFIX wikibase: <http://wikiba.se/ontology#>\nPREFIX bd: <http://www.bigdata.com/rdf#>\n\n\nSELECT DISTINCT ?ms ?msLabel ?hos ?hosLabel \n \nWHERE {\n  ?ms wdt:P463 wd:Q458;\n      wdt:P35 ?hos .\n      SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],en\". }\n}"
    },
    {
        "kind": 1,
        "language": "markdown",
        "value": "get canton berne"
    },
    {
        "kind": 2,
        "language": "sparql",
        "value": "SELECT ?p ?o WHERE {\n    <http://classifications.data.admin.ch/canton/BE> ?p ?o\n} "
    }
]

To create a markdown out of that is looks simple to me. But how to integrate it to vscode? I can image to add a vscode command to it to save the notebook as markdown. Maybe I will try that I don' t know if this is convenient or not.

kvistgaard commented 2 years ago

Doesn't need to use the VSCode save as. A SPARQL notebook command "Export to Markdown" or something like that would be perfect. I'm currently creating an open wiki, initially to support my SPARQL training courses but also to be used as a general reference, where all content is standard markdown with SPARQL code highlighting rendered by CodeMirror, and a few non-standard MD elements that bring the graph experience. So, that's one of many use cases, where reusing the content from a SPARQL notebook as MD will be useful.

BenjaminHofstetter commented 2 years ago

Idea: default markdown serialization

kvistgaard commented 2 years ago

That would be great. Then with tools such as Foam (VSCode), Dendron(VSCode), Logseq and Obsidian, the SPARQL notebooks can be interlinked in between and with other MD files.

BenjaminHofstetter commented 2 years ago

added markdown export