Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
48 changes: 48 additions & 0 deletions apps/vscode/src/test/examples/attr-equals.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Testing equals signs in attribute values

This test document validates that equals signs in attribute values are handled correctly.

## Basic examples

- Basic link with equals in value: [Link text](https://example.com){key=value=with=equals}

- Link with URL parameter: [Query link](https://example.com?param=value){.class key=query=param}

- Span with complex value: [Span text]{#id .class key=complex=value}

## More complex examples

- CSS style with equals: [Styled text]{style=color:red;font-size=12px}

- Math expression value: [Math formula]{formula=E=mc^2}

- Code with equals: `code sample`{lang=c++ key=value=val}

## Code blocks

```{python key=value=equals}
print("Testing equals in attribute values")
```

```{r eval=1+1=2}
print("R code with equals in attributes")
```

## Div with attributes

:::{#div-id key=value=with=multiple=equals}
This is a div with multiple equals signs in attribute values.
:::

## Image with equals signs

![Image caption](image.png){width=50% height=30% key=value=equals}

## Table with equals signs

| Col1 | Col2 |
|------|------|
| A | B |
| C | D |

: Table caption {#tbl-id tbl-colwidths="[50,50]" key=value=with=equals}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Testing equals signs in attribute values

This test document validates that equals signs in attribute values are handled correctly.

## Basic examples

- Basic link with equals in value: [Link text](https://example.com){key="value=with=equals"}

- Link with URL parameter: [Query link](https://example.com?param=value){.class key="query=param"}

- Span with complex value: [Span text]{#id .class key="complex=value"}

## More complex examples

- CSS style with equals: [Styled text]{style="color:red;font-size=12px"}

- Math expression value: [Math formula]{formula="E=mc^2"}

- Code with equals: `code sample`{lang="c++" key="value=val"}

## Code blocks

```{python key=value=equals}
print("Testing equals in attribute values")
```

```{r eval=1+1=2}
print("R code with equals in attributes")
```

## Div with attributes

::: {#div-id key="value=with=multiple=equals"}
This is a div with multiple equals signs in attribute values.
:::

## Image with equals signs

![Image caption](image.png){width="50%" height="30%" key="value=equals"}

## Table with equals signs

| Col1 | Col2 |
|------|------|
| A | B |
| C | D |

: Table caption {#tbl-id tbl-colwidths="\[50,50\]" key=value=with=equals}
2 changes: 2 additions & 0 deletions apps/vscode/src/test/quartoDoc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ suite("Quarto basics", function () {
roundtripSnapshotTest('invalid.qmd');

roundtripSnapshotTest('capsule-leak.qmd');

roundtripSnapshotTest('attr-equals.qmd');
});

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/editor/src/api/pandoc_attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,10 @@ export function pandocAttrKeyvalueFromText(text: string, separator: ' ' | '\n'):

const lines = text.trim().split('\n');
return lines.map(line => {
const parts = line.trim().split('=');
return [parts[0], (parts[1] || '').replace(/^"/, '').replace(/"$/, '')];
const idx = line.indexOf('=');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realized post-hoc that I should probably check if the line here actually has an =?

Copy link
Collaborator

@vezwork vezwork Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I suppose so! like if (idx === -1) return [line, '']; else { bla }

const lhs = line.substring(0, idx).trim();
const rhs = line.substring(idx + 1).trim();
return [lhs, rhs.replace(/^"/, '').replace(/"$/, '')];
});
}

Expand Down