Skip to content

Commit decf745

Browse files
authored
Merge pull request #6833 from EnterpriseDB/DOCS-1560-__output__-content-blocks-eat-up-spaces-but-not-co
DOCS-1560-__output__-content-blocks-eat-up-spaces-but-not-co
2 parents 590f682 + ec35984 commit decf745

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

advocacy_docs/playground/1/01_examples/code-blocks.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ asdasd
3333
asdasd
3434
asdasdafasfa
3535
</pre>
36+
37+
```sql
38+
SELECT * FROM aidb.retrieve_text('test_knowledge_base', 'jacket', 2);
39+
__OUTPUT__
40+
key | value | distance
41+
-------+----------------------------------------------------+--------------------
42+
19337 | United Colors of Benetton Men Stripes Black Jacket | 0.2994317672742334
43+
55018 | Lakme 3 in 1 Orchid Aqua Shine Lip Color | 0.3804609668507203
44+
(2 rows)
45+
```

product_docs/docs/hadoop_data_adapter/2/10c_example_order_by_pushdown.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ __OUTPUT__
6969
---------------------
7070
Foreign Scan on emp
7171
(1 row)
72+
```
7273

74+
```sql
7375
edb=# SET hdfs_fdw.enable_order_by_pushdown TO OFF;
7476
SET
7577
edb=# EXPLAIN (COSTS OFF) SELECT * FROM emp order by deptno;

product_docs/docs/pgd/5.7/quickstart/quick_start_aws.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ Connections Ok All BDR nodes are accessible
275275
Raft Ok Raft Consensus is working correctly
276276
Replication Slots Ok All PGD replication slots are working correctly
277277
Clock Skew Ok Clock drift is within permissible limit
278-
Versions Ok All nodes are running the same PGD version```
278+
Versions Ok All nodes are running the same PGD version
279+
```
279280

280281
Or, you can use `pgd nodes list` to ask PGD to show you the data-bearing nodes in the cluster:
281282

product_docs/docs/pgd/5.8/quickstart/quick_start_aws.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ Connections Ok All BDR nodes are accessible
275275
Raft Ok Raft Consensus is working correctly
276276
Replication Slots Ok All PGD replication slots are working correctly
277277
Clock Skew Ok Clock drift is within permissible limit
278-
Versions Ok All nodes are running the same PGD version```
278+
Versions Ok All nodes are running the same PGD version
279+
```
279280

280281
Or, you can use `pgd nodes list` to ask PGD to show you the data-bearing nodes in the cluster:
281282

src/components/code-block.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState } from "react";
22
import { Button } from "react-bootstrap";
33
import { Tooltip } from "react-bootstrap";
44
import { OverlayTrigger } from "react-bootstrap";
5+
import { useLocation } from "@gatsbyjs/reach-router";
56

67
const childToString = (child) => {
78
if (typeof child === "string") {
@@ -22,12 +23,13 @@ const popExtraNewLines = (code) => {
2223
}
2324
};
2425

25-
const splitChildrenIntoCodeAndOutput = (rawChildren) => {
26+
const splitChildrenIntoCodeAndOutput = (rawChildren, urlpath) => {
2627
if (!rawChildren) {
2728
return [[], []];
2829
}
2930

30-
const splitRegex = /(?:\s+|^)__OUTPUT__\s*(?:\n+|$)/;
31+
// Simplified regex to split on the __OUTPUT__ marker
32+
const splitRegex = /(?:\n|^)[ \t\f\v]*__OUTPUT__[ \t\f\v]*(?:\n|$)/;
3133
const code = [];
3234
const output = [];
3335

@@ -40,6 +42,12 @@ const splitChildrenIntoCodeAndOutput = (rawChildren) => {
4042
if (splitFound) {
4143
// we've already split, toss it into output and move on
4244
output.push(childToString(child));
45+
// warn if we do find another __OUTPUT__ marker - this is likely a mistake
46+
if (splitRegex.test(output.at(-1)))
47+
console.warn(
48+
urlpath +
49+
": Found another __OUTPUT__ marker after the first one, this is likely a mistake.",
50+
);
4351
continue;
4452
}
4553

@@ -151,10 +159,11 @@ const OutputPre = ({ content }) => (
151159
);
152160

153161
const CodeBlock = ({ children, codeLanguages, ...otherProps }) => {
162+
const location = useLocation();
154163
const childIsComponent = !!children.props; // true in normal usage, false if raw <pre> tags are used
155164

156165
const [codeContent, outputContent] = childIsComponent
157-
? splitChildrenIntoCodeAndOutput(children.props.children)
166+
? splitChildrenIntoCodeAndOutput(children.props.children, location.pathname)
158167
: [children, ""];
159168

160169
const startWrapped = false;

0 commit comments

Comments
 (0)