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
@@ -33,6 +33,8 @@ All notable changes to Luce will be documented in this file. | ||
33 | 33 | * Add a new optional parameter `disable_setext_heading` for `BlockParser#parse_lines`, |
34 | 34 | which is used to disable the `SetextHeaderSyntax`. |
35 | 35 | * 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. | |
36 | 38 | * Update GFM to 0.29.0.gfm.7 |
37 | 39 | * Update Regular Expressions to support Crystal 1.8. |
38 | 40 |
@@ -35,3 +35,7 @@ | ||
35 | 35 | <h1 id="1234">1.2.34</h1> |
36 | 36 | <h2 id="1234-2">1.23.4</h2> |
37 | 37 | <h2 id="1234-3">1.2.3+4</h2> |
38 | +>>> no id | |
39 | +# # | |
40 | +<<< | |
41 | +<h1></h1> |
@@ -9,7 +9,10 @@ module Luce | ||
9 | 9 | class HeaderWithIdSyntax < HeaderSyntax |
10 | 10 | def parse(parser : BlockParser) : Node |
11 | 11 | 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 | |
13 | 16 | element |
14 | 17 | end |
15 | 18 | end |