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

最初の見出しからtitle要素を生成するときのルビ記法などの扱い #166

Closed
MurakamiShinyu opened this issue Feb 23, 2023 · 0 comments · Fixed by #178
Closed
Assignees
Labels
bug Something isn't working

Comments

@MurakamiShinyu
Copy link
Member

MurakamiShinyu commented Feb 23, 2023

vfmはマークダウンでの最初の見出しからtitle要素を生成しますが、見出しにルビ記法やHTMLタグが含まれるとき、そのままのテキストとして出力されます。
例:

# {吾輩|わがはい}は猫である。

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{吾輩|わがはい}は猫である。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <section id="吾輩は猫である" class="level1">
      <h1><ruby>吾輩<rt>わがはい</rt></ruby>は猫である。</h1>
    </section>
  </body>
</html>

title要素のテキストを柱に出力する場合などでこれでは不便です。
ルビ記法ならばルビの親文字の部分だけがtitle要素に出力されるのがよいと思います。次のように:

    <title>吾輩は猫である。</title>

また、見出しにHTMLタグが含まれる場合も、タグがそのままテキストとして出力される問題があります。
例:

# 怪人<span class="tcy">20</span>面相

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>怪人&#x3C;span class="tcy">20&#x3C;/span>面相</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <section id="怪人span-classtcy20span面相" class="level1">
      <h1>怪人<span class="tcy">20</span>面相</h1>
    </section>
  </body>
</html>

この場合HTMLタグを除いたテキストだけがtitle要素に出力されるのがよいと思います。次のように:

    <title>怪人20面相</title>

なお、id属性の自動生成でも同様にタグを除いたテキストだけが使われるのがよいでしょう。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants