Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSPのDiagnostics関連の修正とリファクタリング #62

Merged
merged 6 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 10 additions & 19 deletions lua/review.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- -*- coding: utf-8 -*-
-- Re:VIEW Writer for Pandoc
-- Copyright 2020-2023 atusy and Kenshi Muto
-- Copyright 2020 Kenshi Muto
atusy marked this conversation as resolved.
Show resolved Hide resolved

-- config
local config = {
Expand Down 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