yfm-transform
yfm-transform copied to clipboard
fix(plugins/anchors): heading duplicate text content
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
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