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

why first - not displayed in title element? #140

Closed
practicemp opened this issue Feb 1, 2019 · 6 comments
Closed

why first - not displayed in title element? #140

practicemp opened this issue Feb 1, 2019 · 6 comments

Comments

@practicemp
Copy link

In markdown file:
#### --backup-dir=DIR

hexo server output:

<h4 id="–backup-dir-DIR">
    <a href="#–backup-dir-DIR" class="headerlink" title="–backup-dir=DIR"></a>
    –backup-dir=DIR
</h4>

The first - not displayed in the h4 element id & content, also to href and title of the a element .

Then I try this:
#### \--backup-dir=DIR
hexo server output:

<h4 id="backup-dir-DIR">
    <a href="#backup-dir-DIR" class="headerlink" title="--backup-dir=DIR"></a>
    --backup-dir=DIR
</h4>

The first and second - not displayed in the h4 element id , also to href of the a element .

What should i do ?

@tcrowe
Copy link
Contributor

tcrowe commented Feb 1, 2019

I did a test with marked.

./test.md (input)

# --one

one

## --two

two

### --three

three

#### --backup-dir=DIR

four

marked test.md > test.html

./test.html (output)

<h1 id="--one">--one</h1>
<p>one</p>
<h2 id="--two">--two</h2>
<p>two</p>
<h3 id="--three">--three</h3>
<p>three</p>
<h4 id="--backup-dirdir">--backup-dir=DIR</h4>
<p>four</p>

This looks okay. So the next step is to look at where we might be touching the output.


@practicemp You didn't fill out the issue template so I assumed you are using hexo-renderer-marked. If you are using a different markdown renderer you can let me know. npm ls --depth 0

@practicemp
Copy link
Author

@tcrowe
Node version v8.12.0
Hexo and Plugin version

$ npm ls --depth 0
hexo-site@0.0.0 /Users/practicemp/blog
├── hexo@3.8.0
├── hexo-deployer-rsync@0.1.3
├── hexo-generator-archive@0.1.5
├── hexo-generator-category@0.1.3
├── hexo-generator-index@0.2.1
├── hexo-generator-sitemap@1.2.0
├── hexo-generator-tag@0.2.0
├── hexo-renderer-ejs@0.3.1
├── hexo-renderer-jade@0.4.1
├── hexo-renderer-marked@0.3.2
├── hexo-renderer-sass@0.3.2
├── hexo-renderer-stylus@0.3.3
└── hexo-server@0.3.3

The part of the renderer referenced in my theme file (post.pug):

.post-content
    != page.content 

@tcrowe
Copy link
Contributor

tcrowe commented Feb 2, 2019

@practicemp Thanks. I will take another look tomorrow morning and see where we are changing the headings.

@tcrowe
Copy link
Contributor

tcrowe commented Feb 2, 2019

Are you using the toc helper, @practicemp? https://hexo.io/docs/helpers#toc

@practicemp
Copy link
Author

@tcrowe
Yes:

.toc
    != toc(page.content,{list_number: false})

@stevenjoezhang stevenjoezhang transferred this issue from hexojs/hexo Mar 15, 2020
@curbengh
Copy link
Contributor

curbengh commented Aug 21, 2020

it's due to

marked:
  smartypants: true #default

which converts double-dash (--) into en dash (, or &#2013)

a workaround is to disable the option, but that also stop replacing double quote ("") with (“” ), it's fine if you don't need them.

Related to #89

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

No branches or pull requests

3 participants