From 06731b28838a1bcbb0a53293d42a23d649727a12 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 19 Nov 2021 11:26:54 -0700 Subject: [PATCH] Updated oss-/cloud-only shortcodes to work with list items (#3424) * updated oss-/cloud-only shortcodes to work with list items * deduplicated regex passes * Apply suggestions from code review Co-authored-by: Jason Stirnaman Co-authored-by: Jason Stirnaman --- CONTRIBUTING.md | 46 +++++++++++++++++++++++++++ content/example.md | 2 +- layouts/partials/article/content.html | 4 +-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 501571ddf..dbd4e8b71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1034,6 +1034,29 @@ only render in the InfluxDB OSS documentation. This is necessary to get the first sentence/paragraph to render correctly. {{% /oss-only %}} + +- {{% oss-only %}}This is a list item that will only render in InfluxDB OSS docs.{{% /oss-only %}} +- {{% oss-only %}} + + This is a multi-paragraph list item that will only render in the InfluxDB OSS docs. + + **Note:** Notice shortcode is _inside_ of the line item. + There also must be blank newline after the opening short-code tag. + This is necessary to get the first sentence/paragraph to render correctly. + + {{% /oss-only %}} + +1. Step 1 +2. {{% oss-only %}}This is a list item that will only render in InfluxDB OSS docs.{{% /oss-only %}} +3. {{% oss-only %}} + + This is a list item that contains multiple paragraphs or nested list items and will only render in the InfluxDB OSS docs. + + **Note:** Notice shortcode is _inside_ of the line item. + There also must be blank newline after the opening short-code tag. + This is necessary to get the first sentence/paragraph to render correctly. + + {{% /oss-only %}} ``` #### cloud-only @@ -1052,6 +1075,29 @@ only render in the InfluxDB Cloud documentation. This is necessary to get the first sentence/paragraph to render correctly. {{% /cloud-only %}} + +- {{% cloud-only %}}This is a list item that will only render in InfluxDB Cloud docs.{{% /cloud-only %}} +- {{% cloud-only %}} + + This is a list item that contains multiple paragraphs or nested list items and will only render in the InfluxDB Cloud docs. + + **Note:** Notice shortcode is _inside_ of the line item. + There also must be blank newline after the opening short-code tag. + This is necessary to get the first sentence/paragraph to render correctly. + + {{% /cloud-only %}} + +1. Step 1 +2. {{% cloud-only %}}This is a list item that will only render in InfluxDB Cloud docs.{{% /cloud-only %}} +3. {{% cloud-only %}} + + This is a multi-paragraph list item that will only render in the InfluxDB Cloud docs. + + **Note:** Notice shortcode is _inside_ of the line item. + There also must be blank newline after the opening short-code tag. + This is necessary to get the first sentence/paragraph to render correctly. + + {{% /cloud-only %}} ``` #### All-Caps diff --git a/content/example.md b/content/example.md index 49c1c960b..0b627017e 100644 --- a/content/example.md +++ b/content/example.md @@ -2,7 +2,7 @@ title: Example post description: This is just an example post to show the format of new 2.0 posts weight: 1 -# draft: true +draft: true related: - /influxdb/v2.0/write-data/ - /influxdb/v2.0/write-data/quick-start diff --git a/layouts/partials/article/content.html b/layouts/partials/article/content.html index e9d16630d..783cecfdb 100644 --- a/layouts/partials/article/content.html +++ b/layouts/partials/article/content.html @@ -5,9 +5,9 @@ {{ $influxdbCloud := and (eq $product "influxdb") (eq $version "cloud") }} {{ if $influxdbOSS }} - {{ .Content | replaceRE `(?U)(.*<\/span><\!\-\- close \-\-\>)` "" | replaceRE `(?Us)(
.*<\/div><\!\-\- close \-\-\>)` "" | safeHTML}} + {{ .Content | replaceRE `(?Us)(
  • \s*<(?:div|span) class=\'cloud\-only\'>.*<\/(?:div|span)><\!\-\- close \-\-\>\s*
  • )` "" | replaceRE `(?Us)(<(?:div|span) class=\'cloud\-only\'>.*<\/(?:div|span)><\!\-\- close \-\-\>)` "" | safeHTML}} {{ else if $influxdbCloud }} - {{ .Content | replaceRE `(?U)(.*<\/span><\!\-\- close \-\-\>)` "" | replaceRE `(?Us)(
    .*<\/div><\!\-\- close \-\-\>)` "" | safeHTML}} + {{ .Content | replaceRE `(?Us)(
  • \s*<(?:div|span) class=\'oss\-only\'>.*<\/(?:div|span)><\!\-\- close \-\-\>\s*
  • )` "" | replaceRE `(?Us)(<(?:div|span) class=\'oss\-only\'>.*<\/(?:div|span)><\!\-\- close \-\-\>)` "" | safeHTML}} {{ else }} {{ .Content }} {{ end }} \ No newline at end of file