From ccf803de344d52b599406801b308d7396c8e34c6 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Wed, 13 Jul 2022 15:42:23 +0200 Subject: [PATCH] Fix markdig codeblock extension for < and > :bug: --- RELEASE_NOTES.md | 5 + client/docs/CodeExamples.md | 32 ++++ client/docs/PIDs.md | 137 ------------------ client/docs/metadata.md | 14 -- client/docs/sidebars/mainSidebar.md | 7 +- client/loaders/docsloader.fsx | 4 +- .../MarkdigExtensions/nfdi-code.fs | 45 +++--- .../nfdi-code.tests.fs | 12 +- 8 files changed, 73 insertions(+), 183 deletions(-) create mode 100644 client/docs/CodeExamples.md delete mode 100644 client/docs/PIDs.md diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 13a2cc5..57a37fe 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,8 @@ +### 0.5.4+8b01eb5 (Released 2022-7-13) +* Additions: + * latest commit #8b01eb5 + * [[#8b01eb5](https://github.com/Freymaurer/Nfdi4Plants.Fornax/commit/8b01eb56b01e47ddf5a07d7cdef97368bc266914)] Update terser rollup config + ### 0.5.3+da2f374 (Released 2022-7-11) * Additions: * latest commit #da2f374 diff --git a/client/docs/CodeExamples.md b/client/docs/CodeExamples.md new file mode 100644 index 0000000..15651d0 --- /dev/null +++ b/client/docs/CodeExamples.md @@ -0,0 +1,32 @@ +--- +layout: docs +title: Code Examples +published: 2022-05-09 +Author: Dominik Brilhaus +add toc: true +add sidebar: sidebars\mainSidebar.md +Article Status: draft +To-Dos: + - write +--- + + +``` +// Code testing no language + +let x = 2010 +``` + +```fsharp +// Code testing with language + +let x = 20 +``` + +Code testing with inline `code` example! + +```bash +// Code testing with multiple < > + +# https://git.nfdi4plants.org// +``` diff --git a/client/docs/PIDs.md b/client/docs/PIDs.md deleted file mode 100644 index fab9e5e..0000000 --- a/client/docs/PIDs.md +++ /dev/null @@ -1,137 +0,0 @@ ---- -layout: docs -title: Persistent identifiers (PIDs) -published: 2022-05-09 -Author: Dominik Brilhaus -add toc: true -add sidebar: sidebars\mainSidebar.md -Article Status: draft -To-Dos: - - write ---- - - - - - -# Persistent identifiers (PIDs) - - - -- [What are PIDs?](#what-are-pids) -- [Globally unique and persistent](#globally-unique-and-persistent) -- [What can I reference with a PID? How do I assign a PID? And why do I benefit from PIDs?](#what-can-i-reference-with-a-pid-how-do-i-assign-a-pid-and-why-do-i-benefit-from-pids) -- [Common examples for PIDs](#common-examples-for-pids) - - [People](#people) - - [Digital objects and publications](#digital-objects-and-publications) - - [Samples and Resources](#samples-and-resources) - - [Institutions](#institutions) -- [How does DataPLANT support me in using PIDs?](#how-does-dataplant-support-me-in-using-pids) - - - -## What are PIDs? - -Persistent identifiers (PIDs) – as the name suggests – enable to persistently identify a resource (an entity). -This may sound complicated, but consider a (common) daily life example for PIDs: the International Standard Book Number (ISBN). The 13-digit ISBN code allows to unambiguously identify a book without having to specify book author, title or any other detail. Just as the ISBN alone helps to find and order a book at a local retailer, PIDs enable to easily find different entities or resources relevant to (plant) sciences. This can include publications, methods, samples or other experimental materials, softwares and the datasets they produce or the researchers contributing to the earlier. - -## Globally unique and persistent - -Two major requirements of PIDs are the reason they contribute to virtually all aspects of [FAIR][KB-FAIR] data management. PIDs need to be **globally unique** and **persistent**, i.e. they stably resolve to identify the respective resource also in the (foreseeable) future. Global uniqueness is nowadays achieved technically through use of the internet. Put simply: no web address can be duplicated. However, it is good to know that standard URLs (uniform resource locators, "web addresses") cannot be considered PIDs. Sparing the technical details behind PIDs (see [PURLs] and [Handles]), consider the homepage of an institute where a publication was originally stored at the URL `https://plant-science-institute.com/research/publications/publication` and after homepage restructuring moved to `https://plant-science-institute.com/about/outputs/publication`. The earlier URL becomes a "dead link", impossible to be properly resolve and identify the linked publication, a phenomenon known as "link rot". -Although many PIDs resolve to a URL, taking the user to the proper location, they more importantly resolve to the content of the linked digital object (e.g. a dataset or publication). The example shows that the technical layer alone (global uniqueness through web addresses) is not enough to guarantee persistence and prevent "link rot". This is achieved socially through defined policies and institutions: PIDs are actively curated and managed through registration services overseeing that the linked digital object is properly located. - -## What can I reference with a PID? How do I assign a PID? And why do I benefit from PIDs? - -Although basically any imaginable – both analog and digital – entity can be assigned a PID, we mostly focus on PIDs that identify digital objects or resources. However these digital resources themselves maybe descriptors of analog entities such as items at museums, samples from a collection, artistic or musical outputs. The exact benefit and how a resource is assigned a PID depends on the context: what type of entity is referenced with a PID. - -The two best known examples for PIDs used in science are **DOI** (Digital Object Identifier) and **ORCID** (Open Researcher and Contributor ID). -The most established use of DOIs is to identify publications. Similar to an ISBN for a book, a DOI alone suffices to persistently link and refer to a publication, without naming the title, authors or journal. Usually DOIs are not actively requested by standard users, e.g. the authors submitting a manuscript to a journal or data to a repository, but they are assigned during the publication process, e.g. by the journal or data repository acting as the PID registration service. - -An ORCID on the other hand needs to be requested (once) by a researcher. ORCIDs concisely identify researchers independent of identical names between multiple researchers or name changes (e.g. due to wedding). They can actively be curated, e.g. to link and present all publication or other digital outputs. - - - -## Common examples for PIDs - -### People - -- Open Researcher and Contributor ID (ORCID, ) - -### Digital objects and publications - -- Digital Object Identifier (DOI, ) -- ePIC consortium -- Pubmed ID (PMID, ) - -### Samples and Resources - -- Research Resource Identifiers (RRIDs) - -### Institutions - -- Research Organization Registry (ROR, ) -- Global Research Identifier Database (GRID, ) - -## How does DataPLANT support me in using PIDs? - -The following table gives an overview about DataPLANT tools and services related to sharing data. Follow the link in the first column for details. - -Name | Type | Tasks on metadata -----------------|-----------|------------------ -- invenio - - - - -Besides these technical solutions, DataPLANT supports you with community-engaged data stewardship. For further assistance, feel free to reach out via our [helpdesk](https://support.nfdi4plants.org) or by contacting us directly. - - - -1. [KB-FAIR]: Link to knowledgebase article "FAIR principles" -1. [KB-Metadata]: link to article metadata - - -[DataHUB]: "ARC DataHUB" -[ARC]: "ARC specifications" - -[PURLs]: https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator -[Handles]: https://en.wikipedia.org/wiki/Handle_System - - - -- https://www.doi.org/faq.html - - - - - - - - - - \ No newline at end of file diff --git a/client/docs/metadata.md b/client/docs/metadata.md index 0d581bf..7ef71ff 100644 --- a/client/docs/metadata.md +++ b/client/docs/metadata.md @@ -28,20 +28,6 @@ for f in *.md; do pandoc -s -o "${f%.md}.docx" "$f"; done ## What is metadata? -``` -// Code testing no language - -let x = 2010 -``` - -```fsharp -// Code testing with language - -let x = 20 -``` - -Code testing with inline `code` example! - Metadata is "data that provides information about other data"[^1][Merriam]. In order to put some (plant) life into this web dictionary explanation, let us explore metadata with a plant biology example: > Viola investigates the effect of the plant circadian clock on sugar metabolism in *W. mirabilis*. For her PhD project, which is part of an EU-funded consortium in Prof. Beetroot's lab, she acquires seeds from a South-African botanical society. Viola grows the plants under different light regimes, harvests leaves from a two-day time series experiment, extracts polar metabolites as well as RNA and submits the samples to nearby core facilities for metabolomics and transcriptomics measurements, respectively. After a few weeks of iterative consultation with the facilities' heads as well as technicians and computational biologists involved, Viola receives back a wealth of raw and processed data. From the data she produces figures and wraps everything up to publish the results in the *Journal of Wonderful Plant Sciences*. diff --git a/client/docs/sidebars/mainSidebar.md b/client/docs/sidebars/mainSidebar.md index 0e3cfc6..93c91a4 100644 --- a/client/docs/sidebars/mainSidebar.md +++ b/client/docs/sidebars/mainSidebar.md @@ -18,9 +18,6 @@ To-Dos: ## DataPLANT Support:/docs/metadata.html#dataplant-support ``` -```Data Management Plan -# Data Management Plan:/docs/DataManagementPlan.html -## Advantages of a DMP:/docs/DataManagementPlan.html#advantages-of-a-dmp -## Elements of a DMP:/docs/DataManagementPlan.html#elements-of-a-dmp -## DataPLANT's Data Management Plan Generator:/docs/DataManagementPlan.html#dataplants-data-management-plan-generator +```Fornax Testing Example +# Code Examples:/docs/CodeExamples.html ``` \ No newline at end of file diff --git a/client/loaders/docsloader.fsx b/client/loaders/docsloader.fsx index 52d9afe..0df9107 100644 --- a/client/loaders/docsloader.fsx +++ b/client/loaders/docsloader.fsx @@ -30,8 +30,8 @@ let loader (projectRoot: string) (siteContent: SiteContents) = printfn "LOADER CURRENT DOCS: %i" <| Seq.length doc printfn "LOADER ADDING DOCS: %i" <| Seq.length docs - /// Alternative. - let sc = new SiteContents() + // Alternative + // let sc = new SiteContents() docs |> Array.iter siteContent.Add diff --git a/src/Nfdi4Plants.Fornax/MarkdigExtensions/nfdi-code.fs b/src/Nfdi4Plants.Fornax/MarkdigExtensions/nfdi-code.fs index c69b130..168f4aa 100644 --- a/src/Nfdi4Plants.Fornax/MarkdigExtensions/nfdi-code.fs +++ b/src/Nfdi4Plants.Fornax/MarkdigExtensions/nfdi-code.fs @@ -15,26 +15,26 @@ module NfdiCode = type NFDICodeBlockRenderer() = inherit HtmlObjectRenderer() - let extractSourcecode (node: LeafBlock) = - let code = new StringBuilder() - let lines = node.Lines.Lines - let totalLines = lines.Length - let rec appendLines (counter: int) (c: StringBuilder) = - if counter >= totalLines then - c - else - let line = lines[counter] - let slice = line.Slice - if isNull slice.Text then - appendLines (counter + 1) c - else - let lineText = slice.Text.Substring(slice.Start, slice.Length); - if counter > 0 then - appendLines (counter+1) (c.AppendLine().Append(lineText)) - else - appendLines (counter+1) (c.Append(lineText)) - appendLines 0 code - |> fun x -> x.ToString() + //let extractSourcecode (node: LeafBlock) = + // let code = new StringBuilder() + // let lines = node.Lines.Lines + // let totalLines = lines.Length + // let rec appendLines (counter: int) (c: StringBuilder) = + // if counter >= totalLines then + // c + // else + // let line = lines[counter] + // let slice = line.Slice + // if isNull slice.Text then + // appendLines (counter + 1) c + // else + // let lineText = slice.Text.Substring(slice.Start, slice.Length); + // if counter > 0 then + // appendLines (counter+1) (c.AppendLine().Append(lineText)) + // else + // appendLines (counter+1) (c.Append(lineText)) + // appendLines 0 code + // |> fun x -> x.ToString() override this.Write(renderer : HtmlRenderer , cb : CodeBlock ) = @@ -42,11 +42,10 @@ module NfdiCode = let fcb = cb :?> FencedCodeBlock let parser = cb.Parser :?> FencedCodeBlockParser let languageCode = fcb.Info.Replace(parser.InfoPrefix, "").Trim() - let code = extractSourcecode(cb) if languageCode = "" then renderer .Write("") - .Write(code) + .WriteLeafRawLines(cb, true, true, true) .Write("") |> ignore else @@ -57,7 +56,7 @@ module NfdiCode = .Write("") - .Write(code) + .WriteLeafRawLines(cb, true, true, true) .Write("") |> ignore renderer.EnsureLine() |> ignore diff --git a/tests/Nfdi4Plants.Fornax.Tests/nfdi-code.tests.fs b/tests/Nfdi4Plants.Fornax.Tests/nfdi-code.tests.fs index 20fdd24..53b4efe 100644 --- a/tests/Nfdi4Plants.Fornax.Tests/nfdi-code.tests.fs +++ b/tests/Nfdi4Plants.Fornax.Tests/nfdi-code.tests.fs @@ -28,7 +28,7 @@ let someCode = 42 ``` """ let result = Markdown.ToHtml(markdown, pipeline) - let expected = $"""

Test line

{'\010'}let someCode = 42{'\010'}""" + let expected = $"""

Test line

{'\010'}let someCode = 42{'\010'}{'\010'}""" Expect.equal result expected "" } test "Fenced code block" { @@ -38,7 +38,15 @@ let someCode = 42 ``` """ let result = Markdown.ToHtml(markdown, pipeline) - let expected = $"""

Test line

{'\010'}let someCode = 42{'\010'}""" + let expected = $"""

Test line

{'\010'}let someCode = 42{'\010'}{'\010'}""" + Expect.equal result expected "" + } + test "html like structure case" { + let markdown = """``` +# https://git.nfdi4plants.org// +```""" + let result = Markdown.ToHtml(markdown, pipeline) + let expected = $"""# https://git.nfdi4plants.org/<yourusername>/<yourarc>{'\010'}{'\010'}""" Expect.equal result expected "" } ] \ No newline at end of file