diplodoc-platform / diplodoc-platform/transform

fix(plugins/anchors): heading duplicate text content

Open
#333 0 comments 0 reactions 0 assignees View on GitHub
yatalks2023
Dominant language
TypeScript
Stars
69
Forks
59
Avg merge
1d 21h
Merged PRs (30d)
6

Description

selecting heading and copying it leads to duplicate text:

select and ctrl+c on this text:

```
# heading {#anchor}
```

upon doing ctrl+v leads to:

```
heading heading
```

playground example: [https://diplodoc-platform.github.io/playground/?input=%23%2520heading%2520](https://diplodoc-platform.github.io/playground/?input=%23%2520heading%2520%257B%23anchor%257D)

this is happening because every anchor(even implicit one) generates token of type `anchor_hidden_desc` with heading text as content and rendered as a hidden span(all of that is done for SEO purposes).

parser/transformation:

https://github.com/diplodoc-platform/transform/blob/60058e9d477d18f60ba7a1dbd0add0782fb1d504/src/transform/plugins/anchors/index.ts#L24-L29

renderer:

https://github.com/diplodoc-platform/transform/blob/60058e9d477d18f60ba7a1dbd0add0782fb1d504/src/transform/plugins/anchors/index.ts#L161-L163

css rules:

https://github.com/diplodoc-platform/transform/blob/cb621b7fc8022163abc37643521a39ed42e420c9/src/scss/_common.scss#L375-L392

prevent select of hidden text with `user-select: none`

original issue for seo implementation: https://github.com/diplodoc-platform/transform/pull/244

should not affect SEO: https://webmasters.stackexchange.com/questions/99855/is-text-that-use-css-user-select-none-indexed-and-ranked-by-search-engines

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.