• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A Markdown shard for the Crystal programming language


コミットメタ情報

リビジョン4208a0d8eb2cd53d22ce4cee71ffc8102486c692 (tree)
日時2023-05-21 19:23:06
作者supercell <stigma@disr...>
コミッターsupercell

ログメッセージ

Don't generate heading ID when there is no content

変更サマリ

差分

--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,6 +33,8 @@ All notable changes to Luce will be documented in this file.
3333 * Add a new optional parameter `disable_setext_heading` for `BlockParser#parse_lines`,
3434 which is used to disable the `SetextHeaderSyntax`.
3535 * Add a new public getter `previous_syntax` to `BlockParser`.
36+* Fix an issue with `HeaderWithIdSyntax`, do not generate heading IDs for headings
37+ with no content.
3638 * Update GFM to 0.29.0.gfm.7
3739 * Update Regular Expressions to support Crystal 1.8.
3840
--- a/spec/extensions/headers_with_ids.unit
+++ b/spec/extensions/headers_with_ids.unit
@@ -35,3 +35,7 @@
3535 <h1 id="1234">1.2.34</h1>
3636 <h2 id="1234-2">1.23.4</h2>
3737 <h2 id="1234-3">1.2.3+4</h2>
38+>>> no id
39+# #
40+<<<
41+<h1></h1>
--- a/src/luce/block_syntaxes/header_with_id_syntax.cr
+++ b/src/luce/block_syntaxes/header_with_id_syntax.cr
@@ -9,7 +9,10 @@ module Luce
99 class HeaderWithIdSyntax < HeaderSyntax
1010 def parse(parser : BlockParser) : Node
1111 element = super(parser).as Element
12- element.generated_id = BlockSyntax.generate_anchor_hash(element)
12+
13+ unless element.children.nil?
14+ element.generated_id = BlockSyntax.generate_anchor_hash(element) unless element.children.not_nil!.empty?
15+ end
1316 element
1417 end
1518 end