Skip to content

Commit

Permalink
Adjust header spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
aquilesg committed Jul 30, 2024
1 parent 46db897 commit 59b7d0d
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions lua/obsidian/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ end
---@param callout_word string
local function generate_callout_extmarks_header(marks, indent, line, lnum, opts, callout_hl_group_stack, callout_word)
-- Process the > marks leading up to the header
local callout_mark_start_pattern = "[!"
local callout_mark_start_pattern = " [!"
local callout_mark_end_pattern = "%]"

-- Conceal the callout mark
Expand All @@ -547,22 +547,36 @@ local function generate_callout_extmarks_header(marks, indent, line, lnum, opts,
generate_callout_extmarks_body(marks, line, lnum, callout_hl_group_stack, callout_mark_start, callout_mark_end)
-- Ensure callout_mark_start and callout_mark_end are not nil
if callout_mark_start and callout_mark_end then
local end_intro_mark = callout_mark_start + 2
local end_intro_mark = callout_mark_start + 1
log.debug("Generating callout header for:" .. line)
local callout_mark_header = ExtMark.new(
nil,
lnum,
callout_mark_start - 1,
ExtMarkOpts.from_tbl {
end_row = lnum,
-- Just past the ! character
-- Just past the [ character
end_col = end_intro_mark,
conceal = opts.char,
}
)
marks[#marks + 1] = callout_mark_header

-- Generate the reset of the word
-- Generate a space
local callout_mark_header_space = ExtMark.new(
nil,
lnum,
end_intro_mark - 1,
ExtMarkOpts.from_tbl {
end_row = lnum,
end_col = end_intro_mark + 1,
conceal = opts.char,
}
)
marks[#marks + 1] = callout_mark_header
end_intro_mark = end_intro_mark + 1

-- Generate the rest of the word
for i = 1, #callout_word do
local char = callout_word:sub(i, i)
local callout_char_mark = ExtMark.new(
Expand All @@ -579,6 +593,19 @@ local function generate_callout_extmarks_header(marks, indent, line, lnum, opts,
marks[#marks + 1] = callout_char_mark
end_intro_mark = end_intro_mark + 1
end

-- Generate a space
local callout_mark_header_space_trail = ExtMark.new(
nil,
lnum,
end_intro_mark - 1,
ExtMarkOpts.from_tbl {
end_row = lnum,
end_col = end_intro_mark + 1,
conceal = opts.char,
}
)
marks[#marks + 1] = callout_mark_header
end
end

Expand Down

0 comments on commit 59b7d0d

Please sign in to comment.