Skip to content

Commit

Permalink
Merge pull request #62 from atusy/cleanup
Browse files Browse the repository at this point in the history
LSPのDiagnostics関連の修正とリファクタリング
  • Loading branch information
kmuto authored Jul 5, 2023
2 parents 1177b6e + 3228615 commit 8817b5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lua/filters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local function support_blankline(constructor)
local n_break = 0
local content = blocks[i].content

for j, elem in ipairs(x.content) do
for _, elem in ipairs(x.content) do
if elem.tag == "LineBreak" then
-- Count the repeated number of LineBreak
n_break = n_break + 1
Expand Down Expand Up @@ -142,7 +142,7 @@ local function caption_div(div)
end

local function noindent(para)
first = para.content[1]
local first = para.content[1]

if (first and (first.tag == "RawInline") and
(first.format == "tex") and
Expand Down
27 changes: 9 additions & 18 deletions lua/review.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,7 @@ function Para(s)
end

local function attr_val(attr, key)
local attr_table = {}
for k, v in pairs(attr) do
if (k == key and v and v ~= "") then
return v
end
end
return ""
return attr[key] or ""
end

local function attr_classes(attr)
Expand All @@ -180,7 +174,7 @@ local function attr_classes(attr)
end

local function attr_scale(attr, key) -- a helper for CaptionedImage
scale = attr_val(attr, key)
local scale, count = attr_val(attr, key), 0
if (scale == "") or (key == "scale") then
return scale
end
Expand All @@ -195,10 +189,7 @@ local function attr_scale(attr, key) -- a helper for CaptionedImage
end

function Header(level, s, attr)
local headmark = ""
for i = 1, level do
headmark = headmark .. "="
end
local headmark = string.rep("=", level)

local classes = attr_classes(attr)

Expand Down Expand Up @@ -288,7 +279,7 @@ function CodeBlock(s, attr)
end
command = command or "list"

is_list = command == "list"
local is_list = command == "list"


local num = (is_list == false) and "" or (
Expand Down Expand Up @@ -411,7 +402,7 @@ function Table(caption, aligns, widths, headers, rows)
end
local tmp = {}
for i, h in pairs(headers) do
align = html_align(aligns[i])
local align = html_align(aligns[i])
if (config.use_table_align == "true") and (align ~= "") then
h = format_inline("dtp", "table align=" .. align) .. h
end
Expand All @@ -422,7 +413,7 @@ function Table(caption, aligns, widths, headers, rows)
for _, row in pairs(rows) do
tmp = {}
for i, c in pairs(row) do
align = html_align(aligns[i])
local align = html_align(aligns[i])
if (config.use_table_align == "true") and (align ~= "") then
c = format_inline("dtp", "table align=" .. align) .. c
end
Expand Down Expand Up @@ -523,7 +514,7 @@ function Div(s, attr)
local blankline = attr_val(attr, "blankline")
if blankline ~= "" then
local buffer = {}
for i = 1, tonumber(blankline) do
for _ = 1, tonumber(blankline) do
table.insert(buffer, "//blankline")
end
return table.concat(buffer, "\n")
Expand Down Expand Up @@ -586,7 +577,7 @@ function RawInline(format, text)
if (format == "tex") then
return format_inline("embed", "|latex|" .. text)
else
return format_inline("embed", "|" .. format .. "|", text)
return format_inline("embed", "|" .. format .. "|" .. text)
end
end

Expand Down Expand Up @@ -618,7 +609,7 @@ local function configure()

if (metadata) then
-- Load config from YAML
for k,v in pairs(config) do
for k, _ in pairs(config) do
if metadata[k] ~= nil then
config[k] = stringify(metadata[k])
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_reviewlua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def test_inline_font
assert_equal '@<tt>{a\*}', pandoc(src).chomp
src = '`<$>`{.haskell}'
assert_equal '@<tt>{<$>}', pandoc(src).chomp # XXX: ignore attribute
src = '`content`{=tex}'
assert_equal '@<embed>{|latex|content}', pandoc(src).chomp
src = '`content`{=latex}'
assert_equal '@<embed>{|latex|content}', pandoc(src).chomp
src = '~~a~~'
assert_equal '@<del>{a}', pandoc(src).chomp
src = '[Small]{.smallcaps}'
Expand Down

0 comments on commit 8817b5f

Please sign in to comment.