Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quotes to frontmatter #20

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/mdformatter/mdformatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/ioutil"
"os"
"sort"
"strconv"

"github.com/Kunde21/markdownfmt/v2/markdown"
"github.com/bwplotka/mdox/pkg/gitdiff"
Expand Down Expand Up @@ -117,10 +118,18 @@ func (FormatFrontMatter) TransformFrontMatter(_ SourceContext, frontMatter map[s
// Loop through all nested keys.
_, _ = fmt.Fprintf(b, "\n%v:", k)
for key, val := range frontMatterMap {
if v, ok := val.(string); ok {
_, _ = fmt.Fprintf(b, "\n %v: %v", key, strconv.Quote(v))
continue
}
_, _ = fmt.Fprintf(b, "\n %v: %v", key, val)
}
continue
}
if f, ok := frontMatter[k].(string); ok {
_, _ = fmt.Fprintf(b, "\n%v: %v", k, strconv.Quote(f))
continue
}
_, _ = fmt.Fprintf(b, "\n%v: %v", k, frontMatter[k])
}
_, _ = b.Write([]byte("\n---\n\n"))
Expand Down
9 changes: 5 additions & 4 deletions pkg/mdformatter/testdata/formatted.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
weight: 1
type: docs
title: Quick Tutorial
slug: /quick-tutorial.md
menu: thanos
type: "docs"
title: "Quick Tutorial"
slug: "/quick-tutorial.md"
menu: "thanos"
excerpt: "Thanos:"
---

# Quick Tutorial
Expand Down
9 changes: 5 additions & 4 deletions pkg/mdformatter/testdata/formatted_and_transformed.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
weight: 1
type: docs
title: Quick Tutorial
slug: /quick-tutorial.md
menu: thanos
type: "docs"
title: "Quick Tutorial"
slug: "/quick-tutorial.md"
menu: "thanos"
excerpt: "Thanos:"
---

# Quick Tutorial
Expand Down
1 change: 1 addition & 0 deletions pkg/mdformatter/testdata/not_formatted.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Quick Tutorial
type: docs
menu: thanos
excerpt: 'Thanos:'
weight: 1
slug: /quick-tutorial.md
---
Expand Down
30 changes: 17 additions & 13 deletions pkg/mdformatter/testdata/not_formatted.md.diff
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
--- testdata/not_formatted.md
+++ testdata/not_formatted.md (formatted)
@@ -0,10 +0,8 @@
@@ -0,13 +0,11 @@
---
+weight: 1
+type: docs
title: Quick Tutorial
+type: "docs"
-title: Quick Tutorial
+title: "Quick Tutorial"
-type: docs
+slug: "/quick-tutorial.md"
-menu: thanos
+menu: "thanos"
-excerpt: 'Thanos:'
-weight: 1
slug: /quick-tutorial.md
+menu: thanos
-slug: /quick-tutorial.md
+excerpt: "Thanos:"
---

# Quick Tutorial
Expand All @@ -36,7 +40,7 @@

Thanos bases itself on vanilla [Prometheus](https://prometheus.io/) (v2.2.1+). We plan to support *all* Prometheus version beyond this version.

@@ -76,4 +74,4 @@
@@ -77,4 +75,4 @@

If you are not interested in backing up any data, the `--objstore.config-file` flag can simply be omitted.

Expand All @@ -54,7 +58,7 @@

Let's extend the Sidecar in the previous section to connect to a Prometheus server, and expose the Store API.

@@ -95,4 +93,2 @@
@@ -96,4 +94,2 @@
--grpc-address 0.0.0.0:19090 # GRPC endpoint for StoreAPI
```

Expand All @@ -70,7 +74,7 @@

#### External Labels

@@ -167,5 +163,3 @@
@@ -168,5 +164,3 @@

Go to the configured HTTP address, and you should now be able to query across all Prometheus instances and receive de-duplicated data.

Expand All @@ -89,7 +93,7 @@

```bash
thanos query \
@@ -188,4 +182,2 @@
@@ -189,4 +183,2 @@

Read more details [here](service-discovery.md).

Expand All @@ -105,7 +109,7 @@

```bash
thanos store \
@@ -206,1 +198,1 @@
@@ -207,1 +199,1 @@

The store gateway occupies small amounts of disk space for caching basic information about data in the object storage. This will rarely exceed more than a few gigabytes and is used to improve restart times. It is useful but not required to preserve it across restarts.

Expand All @@ -114,7 +118,7 @@

### [Compactor](components/compact.md)

@@ -223,8 +215,4 @@
@@ -224,8 +216,4 @@

The compactor is not in the critical path of querying or data backup. It can either be run as a periodic batch job or be left running to always compact data as soon as possible. It is recommended to provide 100-300GB of local disk space for data processing.

Expand All @@ -139,15 +143,15 @@
```$
usage: thanos rule [<flags>]

@@ -411,1 +399,0 @@
@@ -412,1 +400,0 @@

The configuration format is the following:

-[embedmd]:# (../flags/config_rule_alerting.txt yaml)
```yaml
alertmanagers:
- http_config:
@@ -437,1 +424,4 @@
@@ -438,1 +425,4 @@
timeout: 10s
api_version: v1
```
Expand Down