-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom Lua filter against
# nolint
(and others) (#216)
As suggested in quarto-dev/quarto-cli#8760 The current solution creates a red errors in the render process --------- Signed-off-by: Pawel Rucki <[email protected]>
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
book/_extensions/insightsengineering/pattern-strip/_extension.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
title: Pattern-strip | ||
author: Pawel Rucki | ||
version: 1.0.0 | ||
quarto-required: ">=1.4.0" | ||
contributes: | ||
filters: | ||
- pattern-strip.lua | ||
|
32 changes: 32 additions & 0 deletions
32
book/_extensions/insightsengineering/pattern-strip/pattern-strip.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local patterns = {} | ||
|
||
return { | ||
{ | ||
Meta = function(meta) | ||
if meta['pattern-strip-patterns'] ~= nil then | ||
for _, pattern in ipairs(meta['pattern-strip-patterns']) do | ||
table.insert(patterns, pandoc.utils.stringify(pattern)) | ||
end | ||
end | ||
end | ||
}, | ||
{ | ||
CodeBlock = function (el) | ||
quarto.log.debug(el) | ||
if not el.classes:includes("cell-code") then | ||
return el | ||
end | ||
|
||
local lines = pandoc.List() | ||
local code = el.text .. "\n" | ||
for line in code:gmatch("([^\n]*)\n") do | ||
for _, pattern in ipairs(patterns) do | ||
line = line:gsub(pattern, "") | ||
end | ||
lines:insert(line) | ||
end | ||
el.text = table.concat(lines, "\n") | ||
return el | ||
end | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters