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

Fix an extra space caused by the custom style #74

Merged
merged 1 commit into from
Jan 21, 2023
Merged

Conversation

LightAPIs
Copy link
Contributor

Problem

When using custom style to add ::before pseudo-element on .toc-item element, it causes the <span>${await getHeaderPrefix(header.level)} </span> element to be rendered. Causes the innerText of the .toc-item element to get a space before the string. As a result, the text content of "right click to paste markdown inner link" will have an extra space.

Example

Add the following style to the $profileDir/outline.css file:

.toc-item-1 { counter-reset: item2counter; }
.toc-item-2 { counter-reset: item3counter; }
.toc-item-3 { counter-reset: item4counter; }
.toc-item-4 { counter-reset: item5counter; }
.toc-item-5 { counter-reset: item6counter; }

.toc-item-2:before {
  counter-increment: item2counter;
  content: counter(item2counter) ".";
     opacity: 0.5;
}
.toc-item-3:before {
  counter-increment: item3counter;
  content: counter(item2counter) "."
            counter(item3counter) ".";
     opacity: 0.5;
}
.toc-item-4:before {
  counter-increment: item4counter;
  content: counter(item2counter) "."
            counter(item3counter) "."
            counter(item4counter) ".";
     opacity: 0.5;
}
.toc-item-5:before {
  counter-increment: item5counter;
  content: counter(item2counter) "."
            counter(item3counter) "."
            counter(item4counter) "."
            counter(item5counter) ".";
     opacity: 0.5;
}
.toc-item-6:before {
  counter-increment: item6counter;
  content: counter(item2counter) "."
            counter(item3counter) "."
            counter(item4counter) "."
            counter(item5counter) "."
            counter(item6counter) ".";
     opacity: 0.5;
}

The results below:

space

The reault of copying "Header A" is [test# Header A](:/2fda63fe0401450fa2a4ab093a35da99#header-a).

Solution

Use trim() method removes whitespace from both ends of a string.

@cqroot cqroot merged commit 68a61b3 into cqroot:main Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants