Skip to content

Commit

Permalink
🎨 Improve paragraphs to headings siyuan-note/siyuan#11971
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jul 14, 2024
1 parent 2bd32b7 commit 170030b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions protyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ func (lute *Lute) Blocks2Hs(ivHTML, level string) (ovHTML string) {
p.Type = ast.NodeHeading
if nil != p.FirstChild {
p.FirstChild.Tokens = bytes.ReplaceAll(p.FirstChild.Tokens, []byte("\n"), nil)
p.FirstChild.Tokens = bytes.TrimLeft(p.FirstChild.Tokens, " \t\n")
}
p.HeadingLevel, _ = strconv.Atoi(level)
}
Expand Down
1 change: 1 addition & 0 deletions test/block_type_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestBlocks2Ps(t *testing.T) {

var blocks2hsTests = []*parseTest{

{"3", "<div data-node-id=\"20240714101759-nc7r7j3\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20240714102018\"><div contenteditable=\"true\" spellcheck=\"false\">\t123</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-subtype=\"h1\" data-node-id=\"20240714101759-nc7r7j3\" data-node-index=\"1\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20240714102018\"><div contenteditable=\"true\" spellcheck=\"false\">123</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"2", "<div data-node-id=\"20240702163651-4ww2c7k\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20240702163654\"><div contenteditable=\"true\" spellcheck=\"false\">foo\nbar</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-subtype=\"h1\" data-node-id=\"20240702163651-4ww2c7k\" data-node-index=\"1\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20240702163654\"><div contenteditable=\"true\" spellcheck=\"false\">foobar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"1", "<div data-subtype=\"h2\" data-node-id=\"20210610154900-5r20m2j\" data-node-index=\"1\" data-type=\"NodeHeading\" class=\"h2\" updated=\"20210610154902\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-subtype=\"h2\" data-node-id=\"20210610154909-wemyt8x\" data-node-index=\"2\" data-type=\"NodeHeading\" class=\"h2\" updated=\"20210610154910\"><div contenteditable=\"true\" spellcheck=\"false\">bar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>", "<div data-subtype=\"h1\" data-node-id=\"20210610154900-5r20m2j\" data-node-index=\"1\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20210610154902\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-subtype=\"h1\" data-node-id=\"20210610154909-wemyt8x\" data-node-index=\"2\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20210610154910\"><div contenteditable=\"true\" spellcheck=\"false\">bar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"0", "<div data-node-id=\"20210518185646-hjjhl5p\" data-node-index=\"0\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20210518191256\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20210518191256-m1ij6pn\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" fold=\"0\" updated=\"20210518191257\"><div contenteditable=\"true\" spellcheck=\"false\">bar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20210518185646-pcdktyp\" data-node-index=\"2\" data-type=\"NodeParagraph\" class=\"p\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>", "<div data-subtype=\"h1\" data-node-id=\"20210518185646-hjjhl5p\" data-node-index=\"1\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20210518191256\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-subtype=\"h1\" data-node-id=\"20210518191256-m1ij6pn\" data-node-index=\"2\" data-type=\"NodeHeading\" class=\"h1\" fold=\"0\" updated=\"20210518191257\"><div contenteditable=\"true\" spellcheck=\"false\">bar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-subtype=\"h1\" data-node-id=\"20210518185646-pcdktyp\" data-node-index=\"3\" data-type=\"NodeHeading\" class=\"h1\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit 170030b

Please sign in to comment.